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

Is there any way to make a model go to another model if it is within a certain range of it?

Asked by 6 years ago
Edited 6 years ago

I would put my code here but i dont even know where to start with this, but basically, say model/part A is the animal if model B is within say 50 studs of it, model A moves over to model B. I have looked through the wiki for help but i couldn't find anything. Edit: Preferably smooth movement.

0
You didn't specify how you wanted the teleport to be. Instantaneous, or smooth? I see Function assumed you wanted instantaneous movement. More context! T0XN 276 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

You would just have to get the magnitude of both model's positions.

if (model1.PrimaryPart.Position - model2.PrimaryPart.Position).magnitude <= 20 then
    model1:MoveTo(model2.PrimaryPart.Position)
end

Not very hard, but most people don't know about magnitude. Hope I helped!

Function.

Ad

Answer this question