I made this moving door script but the movement of the door seems too unrealistic: it doesn't slide it just teleports itself small distances, how can I make it to look more natural while maintaining the speed? It also doesn't work with unions I don't know why:
local buttonPressed = false
local wall = script.Parent.Parent.wall:GetChildren()
local dis =150
script.Parent.Touched:connect(function(part)
if not buttonPressed and part.Parent:findFirstChild("Humanoid", true) then
buttonPressed = true
script.Parent.BrickColor = BrickColor.new(21)
for i=0, dis do
for i, v in pairs(wall) do
if v:IsA("Part") or v:IsA("Union") then
v.CFrame = v.CFrame + Vector3.new(0,0,0.1)
wait()
end
end
end
wait(5)
for i=0, dis do
for i, v in pairs(wall) do
if v:IsA("Part") or v:IsA("Union") then
v.CFrame = v.CFrame + Vector3.new(0,0,-0.1)
wait()
end
end
end
wait(5)
script.Parent.BrickColor = BrickColor.new(309)
buttonPressed = false
end
end)

1 comment
try "for i = 1, 16 do," and then experiment with your cframe values until it works the way you like it. This is the for loop I use for all my doors.