I am trying to get the player from a server script, with the following code:

local player = game:GetService("Players").LocalPlayer
local char = player.Character

But it gives an error saying : 09:43:36.442 - ServerScriptService.Script:2: attempt to index nil with 'Character'

Please help!

3 comments

0

Unfortunately you can not get the local player from a server script. You can only retrieve the local player from a "Local Script".

0

You can look at this page if you want to retrieve the player from a "Server Script". https://developer.roblox.com/en-us/api-reference/function/Players/GetPlayers

0

OK thanks