So, I’ve looked around on the Developer Forum and I haven’t been able to find a proper solution to my door.
I’m trying to create a vertical sliding door. Which I’ve accomplished, however, the positioning of the door itself is completely off and I have no clue how to fix that. I am not overly experienced with CFrame or TweenServices.
See here:
Here is my script: (Again, I’m not experienced with this so there is bound to be a mistake)
db = true
script.Parent.ClickDetector.MouseClick:Connect(function()
if db == true then
db = false
local door1 = script.Parent.Parent.door1
local button = script.Parent
button.BrickColor=button.Button.Value
button.ClickDetector.MaxActivationDistance=0
for i = 0.40, 2, 0.40 do
door1.CFrame = CFrame.new(door1.CFrame.X, door1.CFrame.Y + i, door1.CFrame.Z)
wait(0)
end
button.BrickColor=button.ButtonC.Value
button.ClickDetector.MaxActivationDistance=30
else
local door1 = script.Parent.Parent.door1
local button = script.Parent
db = true
button.BrickColor=button.Button.Value
button.ClickDetector.MaxActivationDistance=0
for i = 0.40, 2, 0.40 do
door1.CFrame = CFrame.new(door1.CFrame.X, door1.CFrame.Y - i, door1.CFrame.Z)
wait(0)
end
button.BrickColor=button.ButtonO.Value
button.ClickDetector.MaxActivationDistance=30
end
end)
Perhaps you sould use TweenService for smooth sliding since it is easy to control the speed, the way it slides and the exact position you want it to slide to.