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

Why dose my script work at first then stop working?

Asked by 5 years ago

So I want this script to make it so each time you jump it adds to a leaderboard. I added something where if you have 50 jumps on the leaderboard it will show a gui. It works but when that does that it stops counting how many jumps on the leaderboard please help me fix this. Here is the code:

local plr = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local debounce = false
local debounce2 = false
local Jumps = game.Players.LocalPlayer.leaderstats
local JumpCounter = script.Parent.Parent.Jumps
local Sound = script.Parent.Parent.Sound

plr.Jumping:Connect(function()
    if not debounce then
        debounce = true
        Jumps.Jumps.Value = Jumps.Jumps.Value + 1
        JumpCounter.Text = Jumps.Jumps.Value

        if(game.Players.LocalPlayer.leaderstats.Jumps.Value >= 50) then
            Sound:Play()
            wait(3)
            Sound:Destroy()
            script.Parent.Parent.Frame.Visible = true 
            script.Parent.Parent.Frame.Trail1.Visible = true 

        else
            script.Parent.Parent.Frame.Visible = false
            script.Parent.Parent.Frame.Trail1.Visible = false

        end
        debounce = not debounce
      end
  end)

2 answers

Log in to vote
0
Answered by
Lugical 425 Moderation Voter
5 years ago

Have you tried separating that over 50 jump clause? It could be that once it hits 50 jumps, the gui just keeps playing, rather than an increase in the jump value. Try this:

local plr = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local debounce = false
local debounce2 = false
local Jumps = game.Players.LocalPlayer.leaderstats
local JumpCounter = script.Parent.Parent.Jumps
local Sound = script.Parent.Parent.Sound

plr.Jumping:Connect(function()
    if not debounce then
        debounce = true
        Jumps.Jumps.Value = Jumps.Jumps.Value + 1
        JumpCounter.Text = Jumps.Jumps.Value

        if(game.Players.LocalPlayer.leaderstats.Jumps.Value >= 50) then
            Sound:Play()
            wait(3)
            Sound:Destroy()
            script.Parent.Parent.Frame.Visible = true
            script.Parent.Parent.Frame.Trail1.Visible = true

        else
            script.Parent.Parent.Frame.Visible = false
            script.Parent.Parent.Frame.Trail1.Visible = false

        end
        debounce = not debounce
      end
  end)

if(game.Players.LocalPlayer.leaderstats.Jumps.Value >= 50) then
if debounce2 == false then
debounce = true
            Sound:Play()
            wait(3)
            Sound:Destroy()
            script.Parent.Parent.Frame.Visible = true
            script.Parent.Parent.Frame.Trail1.Visible = true
debounce2 = false
        else
            script.Parent.Parent.Frame.Visible = false
            script.Parent.Parent.Frame.Trail1.Visible = false

        end
0
Trying this now. appleprogamer_59 29 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Instead of debounce = not debounce do debounce = false

Answer this question