Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Anyone knows how to add this script a debounce?

Asked by 2 years ago
Edited 2 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 170 — 2y

1 answer

Log in to vote
0
Answered by 2 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 — 2y
Ad

Answer this question