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

help with adding a debounce?

Asked by 3 years ago

code

function blow(hit) local h = hit.Parent:FindFirstChild("Humanoid")--The Humanoid if (h ~= nil) then --Check If The Humanoid Is There script.Parent.Size = script.Parent.Size + Vector3.new(1,1,1) --The size it will grow once touched wait(100)

end

end

script.Parent.Touched:connect(blow)

i tried to add a debounce but then it stopped working did i do something wrong

2 answers

Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
3 years ago

Try using this

local debounce = false

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        if debounce == false then
            debounce = true

            -- Code here

            wait(3) -- Amount of time for the cooldown
            debounce = true
        end
    end
end)
Ad
Log in to vote
0
Answered by 3 years ago

local db = false

script.Parent.Touched:connect(function(hit) if db == false then db = true

    script.Parent.Size = script.Parent.Size + Vector3.new(1,1,1) --The size it will grow once touched

wait(1)
db = false

end end)

i found out by myself

0
Bruh This Wont Work kidsteve923 139 — 3y
0
THIS WONT WORK kidsteve923 139 — 3y

Answer this question