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

Cant define a player's Character when they join, please help?

My script attempts to change properties in a player's Character whenever they join. I've tried multiple methods to define their character, and have been left with only one that works, but it doesn't technically work the way I want it to.

game.Players.PlayerAdded:Connect(function(client) 
	wait(5) 
	local char = client.Character 
end) 

This does work, but it makes it wait 5 seconds. I'm aware that this will not ALWAYS work, due to the very large range of time it could take up for a player to load their Character in. Please help me with this if you can.

1 answer

✓ Accepted answer

I’m surprised you didn’t come across player.CharacterAdded. It’s an event that fires when the character is added, and returns it.

e.g.

PlayerAdded:Connect(function(player)
     player.CharacterAdded:Connect(function(char)
          print(char)
          print("bruh moment")
     end)
end)

3 comments

1

thanks so much! i really need to look at more events. btw, is there an event to check if a child with a certain name has been added?

1

https://developer.roblox.com/api-reference/event/Instance/ChildAdded <-- use this site, and use an if statement to check the child's name

0

alright thx

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