I've made a door that moves up and down, but the door itself turns 90 degrees when it starts moving. So I tried to add a way to keep the object at the same rotation as it moves down and up but I'm not doing something right?
door = script.Parent.Door
debounce = false
open = true --Door open or not open
script.Parent.DoorToggle.Event:connect(function() --This is a bindable function which is fired from another script
if not debounce then
debounce = true
if open then
for i=10,180 do
door.CFrame = CFrame.new(door.Position + Vector3.new(0,-0.1,0))
door.Rotation = CFrame.Angles(0,90,0) --Something is wrong here
wait()
end
open = false
elseif not open then
for i=10,180 do
door.CFrame = CFrame.new(door.Position + Vector3.new(0,0.1,0))
door.Rotation = CFrame.Angles(0,90,0) --Something is wrong here too
wait()
end
open = true
end
debounce = false
end
end)
I've only recently started learning CFraming.

1 comment
Thanks!