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

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

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)

2 comments

0

Ohh, you got an error becuase its a model

0

Just weld all of the objects to a invisible nocollide block and run the CFrame script on that

1 answer

✓ Accepted answer

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"

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