Ad
Log in to vote
0

help with adding a debounce?

Asked by 1 year 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 614 Moderation Voter
1 year 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 1 year 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 — 1y
0
THIS WONT WORK kidsteve923 139 — 1y

Answer this question