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

Why Won't Players Get Power When They Bounce on the Trampoline?

Asked by 4 years ago

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)
0
Because in the First Script, you refer to it as "Timer" and in the Second, it is set as "Power" theking48989987 2147 — 4y
0
the player function will update to a new player as soon as someone new joins Gameplayer365247v2 1055 — 4y
0
Thank you CJD100100 2 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)
0
Unless I'm doing something wrong, the bonus script isn't working on my trampoline or normal bricks. The fixed version of my script does work on normal bricks, however it doesn't work when I bounce on my trampoline. You can still receive power by standing on the edge of the part, but the second the player fully stands on it they fly into the sky without any power value. CJD100100 2 — 4y
0
It would probably be better to build the power giving script into the bounce script. mbramblet 80 — 4y
0
I can't help to much more unless I know what your players look like, what the trampoline looks like and how the bounce script works. But here it gose: Make shure the power giving script is in a normal "Script" inside the part you touch to bounce. If that doesn't work, put a Print() in the script and see if its fireing or not. mbramblet 80 — 4y
Ad

Answer this question