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

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

Asked by 4 years ago

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

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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)
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? User#28017 0 — 4y
1
https://developer.roblox.com/api-reference/event/Instance/ChildAdded <-- use this site, and use an if statement to check the child's name GoldAngelInDisguise 297 — 4y
0
alright thx User#28017 0 — 4y
Ad

Answer this question