I am trying to create a sliding door made of multiple parts all moving in the same direction. CSG is not an option in this case.
Now, with all of that in mind, I have a script inside a model. The model contains a button, (named "Button"), the "MainDoor" Part, as well as three other parts called "TopDoor." There is also a BoolValue called "IsClosed" that I am using as a switch to keep the doors open and closed.
How should I convert the below script to include the other parts being moved exactly 6.8 units up along the Y axis, keeping them "attached" to the "MainDoor" part?
Code:
door = script.Parent.MainDoor
open = script.Parent.IsClosed
debounce = true
function MoveDoor()
if debounce == true and open.Value then
open.Value = false
debounce = false
for i = 1, 68 do
door.CFrame = door.CFrame + Vector3.new(0, 0.1, 0)
wait()
end
debounce = true
else
if debounce == true then
open.Value = true
debounce = false
for i = 1, 68 do
door.CFrame = door.CFrame + Vector3.new(0, -0.1, 0)
wait()
end
debounce = true
end
end
end
debounce = true
script.Parent.Button.ClickDetector.MouseClick:connect(MoveDoor)

1 comment
Works beautifully, except for a minor flaw that I can fix. Thank you!