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 Connect To the Players body through the PlayerAdded Function? Thanks!!

Im trying to connect to the players body but I'm using a player added function and i haven't used roblox studio in a very long time so if u can help it'll be much appreciated

So... So Far I got this

game.Player.PlayerAdded:connect(function(plr)
...
end

thanks !?!?!

2 answers

✓ Accepted answer

Well to get the character from a player we can do Player.Character so,

game.Player.PlayerAdded:connect(function(plr)
	local char = plr.Character or plr.CharacterAdded:wait()
	-- OR plr.CharacterAdded:wait() because sometimes the character
	-- might not be there
end)

Furthermore we can use the characteradded event of player to do something every time they spawn

game.Player.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function(char)
		print(char.Name)
	end)
end)

Also you were missing a ) in end, end) , in your code.

Use this.

game.Player.PlayerAdded:connect(function(plr)
	local character = workspace:WaitForChild(plr.Name)
end)

Also, you are lucky that I decided not to moderate your question.

3 comments

0

Why is he lucky? He attempted to do it so it doesn't make it incorrect to ask for help.

0

He didnt look at the properties of the player.

0

Not everyone gets stuff the first time around. Your treating this like giving a 6th grader a problem for a college student and if they ask for help telling them they didn't even try. This person may have just started to script and doesn't know how to use the wiki. If so you can't just go off on them.

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