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

how do you debounce more then one function?

how do i do that, tried do it as a whole script in the way it should and didnt work, can you put wait(8.5) in there, i only know how to do it for one function not many

door.Touched:connect(function()

print("yes")

light.PointLight.Color = Color3.new(0, 255, 0)

light.BrickColor = BrickColor.new("Lime green")

light.Material = Enum.Material.Neon

wait(1)

  tweenEopen:Play()

wait(8)

light.PointLight.Color = Color3.new(0, 0, 2)

light.BrickColor = BrickColor.new("Electric blue")

light.Material = Enum.Material.Neon

end)

end

end

end

end)

2 answers

✓ Accepted answer

The description doesn't match the title....

Please create a more better post.

Also on top of that, the code blocks aren't set right.

3 comments

0

the description matches the title coz idk how to debounce more then one function and theres alot of function in the script

0

But where do you want the debounces :rofl:

0

This should be a comment, not an answer.

I don't know what you mean, but this is how debounce works.

local debounce = false

local function ontouched (object)
	if debounce then
		debounce = true
		--script
		wait(8.5)
		debounce = false
	end
end

script.Parent.Touched:Connect(ontouched)

you can also make multiple debounce.

local debounce1 = false
local debounce2 = false

local function ontouched (object)
	if debounce1 == false then
		debounce1 = true
		--script

		if debounce2 == false then
			debounce2 = true
			--script
			spawn(function()
				wait(16)
				debounce2 = false
			end)
		end
		
		wait(8)
		debounce1 = false
	end
end

script.Parent.Touched:Connect(ontouched)

there should be better ways of doing this depending on what you want to do. what this does is if the part is touch it will check if debounce1 is false if it is it will continue set the debounce1 to true and run the script, if debounce2 is false then it will also run that and sets its value to false, the spawn there makes it so that it continues the code without actually waiting for 16 seconds, after that it will continue wait for 8 seconds and set debounce1 to false.

If you want to stop the code if debounce2 is false then add a return after spawn.

1 comment

0

thx bro

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