Beginner scripter trying to make a script that adds to a Variable stored inside of a leaderstats folder. The script works perfectly for about 10-20 touches then gives off this error: attempt to index nil with 'leaderstats'.
Any help appreciated, thanks.
debounce = false
script.Parent.Touched:Connect(function(hit)
if not debounce then debounce = true
local player = game.Players:GetPlayerFromCharacter(hit.Parent);
player.leaderstats.Height.Value = player.leaderstats.Height.Value + 10
wait(1)
debounce = false
end
end)

1 comment
Thanks, why did it work now? The part was never touching anything anyway?