Randomized StarterCharacter

How do you make that your character changes when the player spawns/joins the game without having teams?

For example:

When a player spawns, I want to make that the player is this character:

image

Or this one:

image

The script chooses what character the player will be when he spawns.

Any ideas how do i make it?

Allowed to reply in this post:

Scripts, Ideas or Models

use this:

local char1 = --location of 1 of the chars
local char2 = --location of the other
game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        local choice = math.random(1,2)
        if choice == 1 then
            char = char1:Clone()
        else
            char = char2:Clone()
        end
    end)
end)

That clones the character. Doesn’t transform him into a playercharacter.

1 Like

Alright, let me revise the script, I’m tired lol.

Here is what should work for it:

local char1 = --location of 1 of the chars
local char2 = --location of the other
game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        local choice = math.random(1,2)
        if choice == 1 then
            local newchar = char1:Clone()
            for i,v in pairs(char:GetChildren()) do
                if not v:IsA("Humanoid") then
                    v:Destroy()
                end
            end
            for i,v in pairs(newchar:GetChildren()) do
                if not v:IsA("Humanoid") then
                    v.Parent = char
                end
            end
            newchar:Destroy()
        else
            local newchar = char2:Clone()
            for i,v in pairs(char:GetChildren()) do
                if not v:IsA("Humanoid") then
                    v:Destroy()
                end
            end
            for i,v in pairs(newchar:GetChildren()) do
                if not v:IsA("Humanoid") then
                    v.Parent = char
                end
            end
            newchar:Destroy()        
        end
    end)
end)

You forgot to set a Primary Part. I’ll fix this.

oh, well in the part that I was cloning the stuff from the “newchar”, do this instead (for each):

for i,v in pairs(newchar:GetChildren()) do
    if not v:IsA("Humanoid") then
        v.Parent = char
        if v == newchar.PrimaryPart then
            char.PrimaryPart = v
        end
    end
end

The script works fine but there is one thing missing. Animations.

image

The sizing is fine because my animations still fit with it.

But the character hats be there.

And the script forgets to check for an animation

Just add another check like this when destroying things within the players character:

if not v:IsA("LocalScript") then

end

Thanks but i now lost the intrest with this post. I’m now thinking in a Character Chooser so… yeah…

You need to unanchor the humanoidrootpart so the player can move because the humanoid cannot use animation without the HumanoidRootPart unanchored.