I am trying to move a model up and down, like an elevator, But when I move the Vector up by 0,0.1,0 it will teleport on top of the ceiling and start moving up at an angle upwards, but not straight. My whole goal for the elevator is for it to move up to a certain position slowly. I don't know how to do this any other way with a model.
Code:
` local lift = workspace:WaitForChild("Lift") lift.PrimaryPart = lift.MainPart //sets primary part of model named Lift
for i = 1, 77 do lift:MoveTo(lift:GetModelCFrame().p + Vector3.new(0,0.1,0)) //moves model up by 0.1 on the y axis every loop wait(.1) end `
If someone can either help me find out why the model is teleporting or tell me a better, more clean way of doing my goal, I would be very grateful.
We need to use for loops
local lift = workspace.Lift:GetChildren() for goingUp = BegginingY,EndingY,0.1 do lift.CFrame = CFrame.new(EndingX,goingUp,EndingZ) wait() end for goingDown = EndingY,BegginingY,-0.1 do lift.CFrame = CFrame.new(BegginingX,goingDown,BegginingZ) wait() end
You see We get all of the Parts with the yielding function :GetChildren() And we use CFrame to move them up