Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer
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)

1 comment

0

Thanks man! It works.

This discussion is preserved as it was. New answers, comments, and votes are closed.