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

debounce disables script from working?

local debounce = false

script.Parent.Touched:connect(function(hit)
	if not debounce then
		
		debounce = true
		
		wait(0.3)
	script.Parent.closeddoors.Transparency = 0
	script.Parent.closeddoors.CanCollide = true
	script.Parent.opendoor1.Transparency = 1
	script.Parent.opendoor2.Transparency = 1
	wait(3)
	if hit.Parent:FindFirstChild('Humanoid') then
		hit.Parent.Torso.CFrame = CFrame.new(-13.084, 122.459, 989.779)
		script.Parent.closeddoors.CanCollide = false
	script.Parent.closeddoors.Transparency = 1
	script.Parent.opendoor1.Transparency = 0
	script.Parent.opendoor2.Transparency = 0
	wait()
	debounce = false
	end
end)

the script does not work when i added debounce and my best guess is the wait function at the beginning

but i don't know

1 answer

✓ Accepted answer

Looks like you're missing an end

You have two if statements within your function, but only one end!

local debounce = false

script.Parent.Touched:connect(function(hit)
	if not debounce then

		debounce = true

		wait(0.3)
		script.Parent.closeddoors.Transparency = 0
		script.Parent.closeddoors.CanCollide = true
		script.Parent.opendoor1.Transparency = 1
		script.Parent.opendoor2.Transparency = 1
		wait(3)

		if hit.Parent:FindFirstChild('Humanoid') then
			hit.Parent.Torso.CFrame = CFrame.new(-13.084, 122.459, 989.779)
			script.Parent.closeddoors.CanCollide = false
			script.Parent.closeddoors.Transparency = 1
			script.Parent.opendoor1.Transparency = 0
			script.Parent.opendoor2.Transparency = 0
			wait()
			debounce = false
		end
	end
end)

Indenting helps identify issues like these :)

2 comments

0

Correct

0

kthx

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