Hello, there everybody I am currently having issues with a script I made a few minutes ago and can not figure out why it won't work the GUI is inside lighting and when someone walks up to the counter it gives them the GUI yet that is not the issue the issue is on line 2 of the script I think as player is a nil value?
local player = game:GetService("Players").LocalPlayer
local money = player:WaitForChild("Money")
function onClick()
if player.leaderstats.Profession.Value == "Officer" then
if money.Value >= 500 then
money.Value = money.Value - 500
local M16 = game.ServerStorage.M16:clone()
M16.Parent = script.Parent.Parent.Parent.Parent.Parent.Backpack
script.Parent.Parent.Visible = false
script.Parent.Parent.Parent.Good.Visible = true
else
script.Parent.Parent.Visible = false
script.Parent.Parent.Parent.Error.Visible = true
end
end
end
script.Parent.MouseButton1Click:connect(onClick)
If someone could help me out and help me learn from the mistake that would be great!

1 comment
More along the lines of "Has to be in a local script or it will not work"