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

i tried debounce my script but failed?can someone edit my script to debounce

can u add wait(8.5) in there

can u debounce open door and close door coz they arent the same function, (the door either opens or closes not both)

local hit = false

local keycard = "Keycard"

script.Parent.Touched:Connect(function(hit)

local character = hit.Parent

local player = game.Players:GetPlayerFromCharacter(character)

if player then

local backpack = player.Backpack

if backpack:FindFirstChild(keycard) or character:FindFirstChild(keycard) then

print("opendoor")

else

print("closedoor")

end

end

end)

5 comments

0

no do it yourself. THIS IS NOT A REQUEST SITE

0

i tried

0

Chill

0

Please use codeblocks. It is easier to help you when you do.

0

codeblocks?

1 answer

Code blocks are these ~~~~~~~~~~~~~~~~~

Edit: I did 2 things wrong. Sorry, problem 1 was that the debounce variable name was the same as the name of the input. Problem 2, I didn't even use the debounce as a checking point.

local inside = false

local keycard = "Keycard"

script.Parent.Touched:Connect(function(hit)
	local character = hit.Parent
	local player = game.Players:GetPlayerFromCharacter(character)
	if player and inside == false then
		inside = true
		local backpack = player.Backpack	 
		if backpack:FindFirstChild(keycard) or character:FindFirstChild(keycard) then
			print("opendoor")
		else
			print("closedoor")
		end
		wait(8.5)
		inside = false
	end
end)

2 comments

0

didnt work ;-;

0

Oh I know why

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