Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Weird Model teleportation issue?

Asked by 6 years ago
Edited 6 years ago

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.

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))' MizeryGFX 15 — 6y
0
Put your code on this site, not github, Void_Frost 571 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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

Ad

Answer this question