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

How to get Local Player from server script?

Asked by 9 months ago

This is the only problem holding me off from fixing my game.

game.Players.LocalPlayer does not work and it is confusing me. please help

You can't virushunter9 943 — 9mo
`game.Players.LocalPlayer` only works in a client script. T3_MasterGamer 2189 — 9mo

1 answer

Log in to vote
Answered by 9 months ago

The way you are describing it is not correct.

Let me break it down for you.

game.Players.LocalPlayer cannot be accessed on the server, because only the client and access that value. To see more, search for 'Server-Client Model'. It will give you an understanding of how it works.

But, there is another way of doing this. This might not be a good way, but it's there to be there. Use this line of code:

local player = game.Players.PlayerAdded:Wait()

If you reference the variable, it will say that it returns a Player instance. This is what you're looking for. Am I correct?


Answer this question