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

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

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.

1 comment

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!

1 answer

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.

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