Im trying to make a player’s character change to another character after clicking a button and looping until they leave or it switches again. I tried this.
rs.Events.Play.OnServerEvent:Connect(function(plr)
if not plrspawned[plr] then
local customCharacter = game.ServerStorage.Char:Clone()
plr.Character = customCharacter
customCharacter.Parent = game.Workspace
plr:LoadCharacter()
plrspawned[plr] = true
end
end)
game.Players.CharacterAutoLoads needs to be off, otherwise the game will automatically replace the Character with their default form upon respawn.
The name of the character must match the name of the player
The new character must include a Humanoid and a Head, as well as the animation and sound scripts if you want the character to have animation and sound.
Also LoadCharacter() will just reload the character, replacing your custom character with their default form.
You’re going to have to just manually copy over the GUIs into the Player’s PlayerGui as Roblox doesn’t copy over the items from StarterGui until the character spawns. They have already stated this is a bug and are working on it, but that’s been almost a year now.
Make sure you set the Player’s Custom Character only after they are spawned using LoadCharacter(). Otherwise the character will just respawn in their normal avatar.