FANDOM


This article is a stub. You can help the ROBLOX Wikia by expanding it.

LoadCharacter creates a new character for the player, removing the old one. It also clears the player's Backpack and PlayerGui.

void LoadCharacter (
    bool inGame = true
)

Parameters

inGame

Type: bool

Defaults to: true

Returns: void

Notes

  • This item should be used in a Script to work as expected online.
  • If InGame is false, this will block the main thread when loading the character appearance. Do not set this parameter to false or you will experience bad performance.
  • If the Players's Character is using R15, this function will yield until all of the player's CharacterAppearance assets have loaded.

Example

This script turns off auto-loading and simulates character respawning.

local respawnDelay = 5
 
game.Players.CharacterAutoLoads = false
 
game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		-- find the humanoid, and detect when it dies
		local humanoid = character:FindFirstChild("Humanoid")
		if humanoid then
			humanoid.Died:connect(function()
				wait(respawnDelay)
				player:LoadCharacter()
			end)
		end
	end)
	player:LoadCharacter() -- load the character for the first time
end)

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.