Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you change a Character right when they spawn?

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.

3 comments

0

Line 1, 12 and 13 are not necessary. Then it will work

0

The script will do the exact same thing without those lines. If it's not working, then it's not because of that.

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!

1 answer

✓ Accepted answer

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()

2 comments

0

Also: DO NOT TEST THIS IN PLAY SOLO! PlayerAdded events don't fire in Play Solo. Start a server instead.

0

Yes they do. I have no idea why someone told you that.

This discussion is preserved as it was. New answers, comments, and votes are closed.