Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Weird Model teleportation issue?

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.

2 comments

0

On line 5, try 'lift:GetPrimaryPartCFrame()' or just replace everything in that line with 'lift:SetPrimarypartCFrame(lift:GetPrimaryPartCFrame + CFrame.new(0,0.1,0))'

0

Put your code on this site, not github,

1 answer

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.