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

How to Get Player on a Server Script?

You can get the player on a localscript using

game.Players.LocalPlayer

but how do you get the player on a Server Script without using this function below.

game:GetService('Players').PlayerAdded:connect(function(player)

end)

This function only gets the latest player that joins the game. How do I get only the Player, currently playing the game on a server script, just how LocalPlayer works?

1 comment

0

Thank you appreciate the answer.

1 answer

✓ Accepted answer

There is no way, it's called a server script. You could use a remote event to get it from the client. Some other ways though

for index, player in pairs(game.Players:GetPlayers()) do
	-- script
end

This runs for all players

or this one

game.Players.PlayerAdded:connect(function(plr)

end)

This is probably your best option as it is pretty much the same as a localplayer. This does NOT only gets the latest player.

There is no other option if you don't know the way, your best option would be 'remote events' even if you hate it like a lot of people :/

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