In my game players should get +1 Power on the leaderboard for bouncing on a trampoline I made. I created a trampoline by anchoring a part and changing its y-velocity. The bouncy part is also a part of a model made up of multiple parts if that makes a difference, but I have also already tried the script with plain bricks and had no luck.
game.Players.PlayerAdded:connect(function(player) local debounce = true script.Parent.Touched:connect(function() local plrstats = player.leaderstats.Timer if debounce then debounce = false plrstats.Value = plrstats.Value +1 wait(2) debounce = true end end) end)
I am also providing my leaderboard script in case it is useful.
game.Players.PlayerAdded:connect(function(player) local Stats = Instance.new("Model", player) Stats.Name = "leaderstats" local Timer = Instance.new("IntValue", Stats) Timer.Name = "Power" Timer.Value = 0 end)
You named the value "Power", but have the other script looking for "Timer".
Just change line 4 of the ontouch script:
local plrstats =player.leaderstats.Power
As a bonus, here's a edited version of the ontouch script that may fix some other unintended issues with the original.
I hope it helps:
local debounce =true local plrstats script.Parent.Touched:connect(function(part) if debounce and game.Players:FindFirstChild(part.Parent.Name)then debounce =false plrstats =game.Players:FindFirstChild(part.Parent.Name).leaderstats.Power plrstats.Value =plrstats.Value +1 wait(2) debounce =true end end)