PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

CharacterAppearanceId

Player

int64

The CharacterAppearanceId property determines the user ID of the account whose character appearance is used for a player’s character. By default, this property is that of the Player's Player/UserId, which uses the player’s account appearance as they have created it on the Roblox website.

Changing this property to the user ID of another account will cause the player to spawn with that account’s appearance (hats, shirt, pants, etc). Try setting this property to your friend’s user ID to look like them in-game!

Games can also toggle whether or not a player’s character appearance is loaded in game by changing the StarterPlayer/LoadCharacterAppearance property.


Code Samples


Disguise Command

This code sample allows players to chat “/disguise xyz”, where xyz is a user ID or username, and they will respawn appearing like that account’s avatar. Try typing “/disguise 261” or “/disguise Shedletsky”!

local Players = game:GetService("Players")

local disguiseCommand = "/disguise "

local function onPlayerChatted(player, message)
	if message:sub(1, disguiseCommand:len()):lower() == disguiseCommand:lower() then
		local input = message:sub(disguiseCommand:len() + 1)
		local id = tonumber(input) -- Parse a number, or return nil if not a number
		if not id then -- Number failed to parse, maybe they typed a username instead
			pcall(function () -- This call can fail sometimes!
				id = Players:GetUserIdFromNameAsync(input) -- Fetch ID from name
			end)
		end
		if id then
			-- Set character appearance then respawn
			player.CharacterAppearanceId = id
			player:LoadCharacter()
		else
			-- We couldn't get an ID from their input
		end
	end
end

local function onPlayerAdded(player)
	player.Chatted:Connect(function (...)
		onPlayerChatted(player, ...)
	end)
end

-- Listen for players being added
for _, player in pairs(Players:GetPlayers()) do
	onPlayerAdded(player)
end
Players.PlayerAdded:Connect(onPlayerAdded)