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

Players:vxcaie.Backpack.Energy.Script:1: attempting to index nil with 'leaderstats"?

Asked by 2 years ago
Edited 2 years ago

So when I tried finding the leaderstats so I could earn some points for my stats, this error appeared: "Players:vxcaie.Backpack.Energy.Script:1: attempting to index nil with 'leaderstats"

Note: It says "vxcaie" because i actually changed my username recently so it doesn't say vxcaie in this website.

Script:

energyamt = game.Players.LocalPlayer.leaderstats.Power
db = true
script.Parent.Activated:Connect(function()
    if db == false then
        db = true
        energyamt.Value  = energyamt.Value + 1
        db = false
        wait(2)
    end
end)

1 answer

Log in to vote
1
Answered by 2 years ago
local tool,debounce=script.Parent,nil
local power=tool.Equipped:Wait()and game.Players[tool.Parent.Name].leaderstats.Power
tool.Activated:Connect(function()
    if debounce then return end
    debounce=true
    power.Value+=1
    wait(2)
    debounce=false
end)
0
Thanks man! It works. RektwayYTB 123 — 2y
Ad

Answer this question