This property determines the user ID of the account whose character appearance is used for a player’s
character. By default, this property is thePlayer
'sPlayer/UserId`, which uses the player’s avatar 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).
Games can also toggle whether or not a player’s character appearance is loaded in game by changing the
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)