Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you change a Character right when they spawn?

Asked by 10 years ago

So I'm trying to make a script that when a player spawns, I insert a Character into them, It kinda makes no sense. Here --

function Joke()
    game.Players.PlayerAdded:connect(function(Player)
        Player.CharacterAdded:connect(function(Character)
        local Head = Player.Character:FindFirstChild("Head")
if (Head ~= nil) then
    Head.BrickColor = BrickColor.new("Toothpaste")
end


        end)
    end)
    end
Joke()

I've tried it with everything. Hope I get a good answer.

0
Line 1, 12 and 13 are not necessary. Then it will work fahmisack123 385 — 10y
0
The script will do the exact same thing without those lines. If it's not working, then it's not because of that. 2eggnog 981 — 10y
0
Nope, didn't work. Eh, Really doesn't matter, I'll do it tomorrow, I'm EXHAUSTED. Maybe my mind needs some rest. Thanks anyways. :D! offbeatpizzalives123 105 — 10y

1 answer

Log in to vote
1
Answered by
2eggnog 981 Moderation Voter
10 years ago

Roblox is getting the head's color from the Body Colors object after you've already set it. To fix this, we can set the HeadColor property of the Body Colors rather than directly changing the head's color.

function Joke()
    game.Players.PlayerAdded:connect(function(Player)
        Player.CharacterAdded:connect(function(Character)
            repeat wait() until Character.Parent --Waits until the character has fully spawned
            local BodyColors = Character:WaitForChild("Body Colors")
            BodyColors.HeadColor = BrickColor.new("Toothpaste")
        end)
    end)
end
Joke()
0
Also: DO NOT TEST THIS IN PLAY SOLO! PlayerAdded events don't fire in Play Solo. Start a server instead. Perci1 4988 — 10y
0
Yes they do. I have no idea why someone told you that. 2eggnog 981 — 10y
Ad

Answer this question