Keybind door won't close, no errors or anything in output

So I made a door and followed a tutorial on how to keybind it, and everything was going well until i opened the door, it was fine until I attempted to close it, it would not close, I tried redoing the motor6d, it still wouldn’t work, i checked the script and there were no errors in analysis or output, this is the script that allows it to open and close.

door = the door
AB = motor6d

i legitimately have no idea what was going wrong
(there is another script but that is what fires the event)

local Door = script.Parent.Door

script.Parent.ToggleDoor.OnServerEvent:Connect(function()
	if Door.Transparency == 0 then
		script.Parent.AB.Open.DesiredAngle = -1.6
		Door.CanCollide = false
	else
		Door.Transparency = 0
		script.Parent.AB.Open.DesiredAngle = 0
		Door.CanCollide = true
	end

end)

Sorry that I am not able to help, but I think this belongs more on scripting support, try over there instead.

Good luck!

1 Like

you set the Door transparency to 0 but never set it otherwise.

I only added the transparency lines because it wouldn’t work without them, the door isn’t one of those doors where when you click it, it turns invisible and another turns visible. its a motor6d door that when you press e in front of it, it makes the motor6d desired angle -1.6

Yes I understand, however your if statement states

if Door.Transparency == 0 then

which means since the transparency is 0 it will keep running this

script.Parent.AB.Open.DesiredAngle = -1.6
Door.CanCollide = false

an easy fix would be just to change the transparency or to use a debounce instead

		script.Parent.AB.Open.DesiredAngle = -1.6
		Door.CanCollide = false
                Door.Transparency = 1

With debounce

local db = false
local Door = script.Parent.Door

script.Parent.ToggleDoor.OnServerEvent:Connect(function()
	if db == false then
        db = true
		script.Parent.AB.Open.DesiredAngle = -1.6
		Door.CanCollide = false
	else
        db = false
		Door.Transparency = 0
		script.Parent.AB.Open.DesiredAngle = 0
		Door.CanCollide = true
	end
end)
1 Like

Thank you! The debounce method worked!

1 Like