How to properly get the local player from both scripts?

So im actually curious now, how can i actually get the LocalPlayer as i will have.


-- and also


Is it actually possible using a script or only a localscript? If you want to do something like this:

	if plr and plr:FindFirstChild("Humanoid") then
		-- rest of da code with plr character

In this case i was using a LocalScript
But if my case was a regular script it would Not interact with the LocalPlayer.

So im curious, is here a way to get it in a Script?


In local script you can use game.Players.LocalPlayer.

In server you cant get local player, you can only get player that interact with buttons etc.

Please shift this topic to #help-and-feedback:scripting-support so it doesn’t get taken down.

As for finding the LocalPlayer, it will differ. You can use events like PlayerAdded to get the Player’s instance. However, there are some instances in the Player that are locked to being accessible only in LocalScripts. It would depend on what you’re trying to do.

But server can acces player gui…

1 Like

That was my bad, thanks for correcting.