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

How to get Local Player from server script?

Asked by 2 years 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

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

1 answer

Log in to vote
1
Answered by 2 years 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?

Ad

Answer this question