So basically I am trying to get the player from a server script but I just cannot get it. Does anyone know how to do this?
There are multiple ways to get a single player using server. Remote events and in pairs loops. I'll show you both ways.
In Pairs Loop
for _, v in pairs(game.Players:GetPlayers()) do end
PlayerAdded Event
game.Players.PlayerAdded:Connect(function(plr) end)
Remote Events (Note: You should only use Remote Events IF you're gonna use GUIs and stuff, so I do not use recommend using it.)
--Local Script-- local remoteEvent = game.ReplicatedStorage.RemoteEvent remoteEvent:FireServer(game.Players.LocalPlayer) --Server Script-- game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function() end)
Also you can use game.Players:GetPlayerFromCharacter()
on certain events such as the Part.Touched
event.
A serverscript doesnt work local, try it in a localscript.
game.Players.LocalPlayer