How to change player character with custom character?

Hello
I have tried to change player character with the custom character with the following code

for i,v in pairs(game.workspace.GalaxySMediaXz:GetChildren()) do
if not v:IsA("Script") and not v:IsA("LocalScript") then
v:Destroy()
end
end
for i,v in pairs(game.CustomCharacter:GetChildren()) do 
v:Clone().Parent = workspace.GalaxySMediaXz
end

it works but the animation does not work and the accessories have a bug too

So I want to know if there are better solutions

Thank! and sorry for bad English

EDIT: So I have tried different code and still doesn’t work

3 Likes

Use this:

game.Players.PlayerAdded:Connect(function(player) 
    player.CharacterAppearanceLoaded:Connect(function(character) --CharacterAdded works too but it occasionally errors, for me anyway.
        for i,v in pairs(character:GetDescendants()) do
            v:Destroy() --Include some lines to ensure that the torso and head don't get destroyed or else the player will die.
        end
        for i,v in pairs(game.CustomCharacter:GetChildren()) do
            v:Clone().Parent = player.Character --Don't use the direct reference to the character via Workspace in case another model is named after it.
        end
    end)
end)

So this would run every time their current character loads, then we destroy it and replace it with the custom character. Your current code would only run once, and perhaps the player’s character has not loaded yet. There may be a better alternative, but this is what I would do anyway haha.

7 Likes

If you want all players to be this character by default, name the character “StarterCharacter” and place it inside of StarterPlayer.

image

My tutorial on how to make a custom character might help you out as well: How to make a custom character in your game

2 Likes

I just want it to run just one time because i will do a be the monster gamepass but let me try your script

1 Like

I just wanna do be the monster gamepass so i just wanna run it one time

2 Likes

See this tutorial by a youtuber named:
RIPPER0NI