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

idk how to debounce so can someone debounce this script?

make it pressable every 8.5 seconds, pressed only once every 8.5 seconds

local time = 3 -- time the player has before door closes script.Parent.Touched:Connect(function(hit) if hit.Parent.parent:FindFirstChild("Keycard") then print("what are you") wait(1)

elseif not hit.Parent.parent:FindFirstChild("Keycard") and hit.Parent.parent:FindFirstChild("Humanoid") then	

print("doing step bro") end end)

5 comments

0

bye

0

Sorry, your not suppose to ask for code on this site. You can ask for help here, or suggestions. Most people won't help you if your not trying.

0

i cant try if i dont know

0

Basically you make a variable named debounce that = false. Then you would put an if statement to see if its false, before your code happens. Then you would make your debounce true. After your code, you can make your debounce false, which will then let your code repeat again.

0

The debounce would just be there, to make sure yourcode doesn't repeat to fast.

1 answer

✓ Accepted answer
local Hit = false

script.Parent.Touched:Connect(function(hit)
	if Hit == false then
		if hit.Parent.parent:FindFirstChild("Keycard") then 
			Hit = true
			print("what are you") 
			wait(8.5)	-- Make it touchable only after 8.5s, is this what u mean?
			Hit = false	
		elseif not hit.Parent.parent:FindFirstChild("Keycard") and hit.Parent.parent:FindFirstChild("Humanoid") then   
			Hit = true -- Im not sure if you need this but if no, just delete it
			print("doing step bro") 
			Hit = false -- same for this
		end
	end
end)

3 comments

0

nice

0

the part after elseif not didnt work but the other part did

0

my discord is Bruh#9228

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