I was making a game where you need to buy levels and while writing the script there was a problem attempt to index nil with ‘leaderstats’
Script:
local player = game:GetService(“Players”).LocalPlayer
function Hi()
if player.leaderstats.Coin.Value >= 5 then
player.leaderstats.Coin.Value = player.leaderstats.Coin.Value - 5
script.Parent:Destroy()
end
end
local player = game:GetService("Players"):GetChildren(plr)
function Hi()
if plr.leaderstats.Coin.Value >= 5 then
plr.leaderstats.Coin.Value = plr.leaderstats.Coin.Value - 5
script.Parent:Destroy()
end
end
script.Parent.MouseButton1Down:Connect(Hi)