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

Script gives a nil value warning?

Asked by 5 years ago

In my game, it gives me a warning Workspace.Admin:2: attempt to index field 'Parent' (a nil value)

local GUI = script.Parent.Parent;
local player = GUI.Parent.Parent;
local user = player.Character;
local cam = workspace.CurrentCamera;

I hope that someone could help me.

0
whats the parent of this script, starmaq 1290 — 5y

1 answer

Log in to vote
0
Answered by
blockmask 374 Moderation Voter
5 years ago

If you are using a local script, instead of defining the player by GUI.Parent.Parent, define the player as a LocalPlayer, and I see that on line 3 of your's, you're defining the player's character. What if the player's character was never loaded?

local player = game.Players.LocalPlayer
local character = player.CharacterAdded:Wait() or player.Character
0
Since you didn't provide enough details, I couldn't help you out any further. Please make sure you include the details of your answer when posting blockmask 374 — 5y
2
:dab: starmaq 1290 — 5y
Ad

Answer this question