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

Anyone knows how to add this script a debounce?

Asked by 6 years ago
Edited 6 years ago
local Spirit = script.Parent

 Spirit.Touched:connect(function(entity)

     if entity.Parent.Name == "WaterEssence" and game.Players:FindFirstChild(entity.Parent.Parent.Name) 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)

        wait(20)               

     end

 end)

Help please. SuVee, Aspiring Dev

0
Connect not connect User#19524 175 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Add a DeBounce variable.

local debounce = false -- Set to false first 

We will then in your first if statement say:

-- Add this to your first if statement
if not debounce then
    debounce = true
    -- wait() If you want to wait for it to run again.
    debounce = false 
end
0
Thanks! SuperBeeperman 30 — 6y
Ad

Answer this question