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

help with adding a debounce?

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

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

2 comments

0

Bruh This Wont Work

0

THIS WONT WORK

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)

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