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

[SOLVED] The server script does not get the player or player's character?

Asked by 3 years ago
Edited 3 years ago

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!

0
Unfortunately you can not get the local player from a server script. You can only retrieve the local player from a "Local Script". iDarkGames 483 — 3y
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 iDarkGames 483 — 3y
0
OK thanks NathanBlox_Studios 212 — 3y

Answer this question