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

How do I teleport this model offset from where it currently is?

Asked by 5 years ago

How do I get the current position of the Egg. The Egg is a model. I want to move it as a whole from where it is in the present

--minecraft dragon egg

bounce = true

function teleportEgg()

if bounce == true then

bounce = false

x1 = math.random(-25, 25)

y1 = math.random(-1, 1)

z1 = math.random(-25, 25)

script.Parent.Parent:MoveTo()

wait(0.1)

bounce = true

end

end

script.Parent.ClickDetector.MouseClick:Connect(teleportEgg)

0
Ohh, you got an error becuase its a model Fad99 286 — 5y
0
Just weld all of the objects to a invisible nocollide block and run the CFrame script on that Fad99 286 — 5y

1 answer

Log in to vote
0
Answered by
pidgey 548 Moderation Voter
5 years ago

Use the TranslateBy function. "Shifts a Model by a given Vector3 offset" I believe this is exactly what you're describing. Note that if any object is in the way of its position, "the Model will overlap said object" An alternative option is to use the MoveTo function, and add the current position of the model (Model.PrimaryPart) with an offset as its argument.

Model:MoveTo( Model.PrimaryPart.Position + Vector3.new(0, 1, 0) ) --moves this model up by 1 stud from its current position.

If you use MoveTo instead of TranslateBy, the differences are as follows: "the model will be moved up in the Y direction until there is nothing in the way" and "the rotation is not preserved when moving a model"

Ad

Answer this question