What does Players.TheNyghtmare.PlayerGui.Shop.Frame.Main.Item1.Script:6: attempt to index local 'player' (a nil value) mean in this situation?
My script is below:
script.Parent.MouseButton1Click:connect(function()
local RS = game:GetService("ReplicatedStorage")
local item = RS:WaitForChild("Sword")
local price = 250 -- Change Your Price Here
local player = game.Players.LocalPlayer
local stats = player:WaitForChild("leaderstats")
if stats.Coins.Value == price then -- Change the Money to your Currency Name
stats.Coins.Value = stats.Coins.Value - price
local cloned = item:Clone()
local cloned2 = item:Clone()
cloned2.Parent = player.Backpack
cloned.Parent = player.StarterGear
end
end)
Output error:
01:02:13.152 - Players.TheNyghtmare.PlayerGui.Shop.Frame.Main.Item1.Script:6: attempt to index local 'player' (a nil value) 01:02:13.153 - Stack Begin 01:02:13.155 - Script 'Players.TheNyghtmare.PlayerGui.Shop.Frame.Main.Item1.Script', Line 6 01:02:13.156 - Stack End
