You need to use CFrame, not Position, when moving the door.
ROBLOX is stupid, and if you use Position, it won't allow intersections between two difference parts.
#Edit
As other people have pointed out, you also apparently can't set on a single axis.
#End edit
door = Workspace.NAAFBunker.Door
while door.Position.y < 20.1 do
door.CFrame = door.CFrame * CFrame.new(0, 0.1, 0)
wait(0.1)
end
wait(5)
while door.Position.y > 11.0 do
door.CFrame = door.CFrame * CFrame.new(0, 0.1, 0)
wait(0.1)
end
However, you can also use the strangely named "lerp" method for slightly nicer, more efficient code.
door = Workspace.NAAFBunker.Door
height = door.Size.y
closedCFrame = door.CFrame
openCFrame = closedCFrame * CFrame.new(0, height, 0)
for i = 0, 1, 0.05 do
door.CFrame = closedCFrame:lerp(openCFrame, i)
wait(0.1)
end
wait(5)
for i = 0, 1, 0.05 do
door.CFrame = openCFrame:lerp(closedCFrame, i)
wait(0.1)
end
or something along those lines
NB
The reason we don't use == and ~= when working with decimals is because computers don't actually store them properly. What looks like a 2.1 is probably actually a 2.1000000003 or something.
The operators == and ~= check for exact equality, so if we're checking for 2.1 and the real value is 2.100000003, they won't work as we expect.
6 comments
You can't set the individual axes, and due to floating point imprecision your while loop might be an infinite loop.
he say do >= not ~=
Or <
also u didnt show the script for the button so we dont even know if that would work.
dont sass me incapaz he knows what i mean
yeah INCAPAble!!