I have been trying to find a way to make a part follow a specific person when they get close, but I can't find out a way to get the person's name and tell the part which person to go towards without making a script with the specific person's name in it. Can someone help me?
✓ ANSWER ACCEPTED
How do I get a player's name when the player joins the game?
1 answer
✓ Accepted answer
Use a PlayerAdded event!
Using the Players Service, we can tell when a player joins the game and get that specific player. Example,
-- Regular script
game.Players.PlayerAdded:connect(function(plr)
print(plr.Name)-- Prints players' names
end)
Your question didn't say much about the follow brick thing, and you should try doing that yourself before posting another question.
How do I get the character?
This is what I think you meant. We can use the CharacterAdded event of the player we got from the PlayerAdded event. Example,
-- Regular script
game.Players.PlayerAdded:connect(function(plr)-- Gets the player
plr.CharacterAdded:connect(function(char)-- Gets the character
local Torso = char:WaitForChild("Torso")-- Gets the torso
end)
end)
I also got the Torso defined for you so you can make that follow brick!
Good Luck!
If I helped, please don't forget to accept my answer.
This discussion is preserved as it was. New answers, comments, and votes are closed.
