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
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 :)