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

[STILL UNANSWERED] EXP Debounce is not working, can someone tell me why?

the thing i need help with is pretty easy, its just how to do so players cant spam the EXP getting, i tried adding debounce but its not working, help?

local debounce = false
local Spirit = script.Parent
 Spirit.Touched:connect(function(entity)
     if entity.Parent.Name == "WaterEssence" and game.Players:FindFirstChild(entity.Parent.Parent.Name)and debounce == false then
        local Man =  entity.Parent.Parent.Parent
        local RealMan = game.Players:FindFirstChild(entity.Parent.Parent.Name)
        local Bro = RealMan:FindFirstChild("leaderstats")
        local EXP = Bro:FindFirstChild("EXP")
        EXP.Value = EXP.Value + 10
        print(EXP.Value)
        local debounce = true
        wait(20) 
        local debounce = false                
     end
 end)

thanks

EDIT think i found the problem, maybe its because at the start of the script it says "local debounce = false" so maybe anytime i run the script it goes back to false. can someone tell me how to fix this?

2 comments

0

Is the problem that the players can still get xp or that they can't get xp at all.

0

replace "local debounce" with just "debounce" in the function only.

2 answers

Move local debounce = true to line 5 so it runs before you give EXP and see if that helps.

You should move debounce = true to between lines four and five. Your debounce will only work for one second after your 20 second delay, because the if statement will keep returning true until debounce is true, which you do after your delay. Good luck!

2 comments

0

still not working

0

Try removing local from the beginning of debounce, everywhere except on line one. Combine that with the explanation above, and your script should work fine.

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