Just a simple question, How to make a player variable in a normal script?
✓ ANSWER ACCEPTED
How to make a player variable in a normal script?
1 answer
✓ Accepted answer
You cannot get the player directly on the server with LocalPlayer, however there are some ways to get the player without it.
Method 1: PlayerAdded This method will get a variable of the player whenever a player joins the game. Example:
game.Players.PlayerAdded:Connect(function(plr)
print(plr.Name) --this will print the name of all players who join.
end)
Method 2: RemoteEvent This method allows the client to send a message to the server (local script to server/normal script). Said message has arguments, and the first argument will always be the client (aka player) who sent it. Example:
--in a localscript
game.ReplicatedStorage.Remote:FireServer()
--in a normal/server script
game.ReplicatedStorage.Remote.OnServerEvent:Connect(function(plr)
print(plr.Name) -- will print whatever client sent that event.
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
I can answer in a minute or so, there's a timer on answering, but you would use game.Players.PlayerAdded