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

Can't remember how to move a model, help?

I know I know how to do this, it's just been forever sine I've programmed using roblox and I can't for the life of me remember how to do it. I need to move a model to another parts position, but for some reason it wont work.

local dwell = game.ReplicatedStorage.enemies["Dungeon Dweller"]

local enemy = dwell:Clone()
enemy.Parent = game.Workspace
enemy:MoveTo(Vector3.new(script.Parent.Position))

(script is located in the part I'm trying to move the model to)

If I include "Vector3.new", it just moves to model to the position (0,0,0) with no errors. If I remove "Vector3.new", it just clones the model to workspace but doesn't move it at all from its preset position in workspace (again, no errors).

1 comment

0

postion is a vector 3

2 answers

enemy:MoveTo(Vector3.new(script.Parent.Position))

Here's your problem, you're making a Vector3, with a Vector 3. Position provides a Vector3.

If you're needing more, tell us. But I'm also somewhat sure that :MoveTo() is a method of a humanoid, not a model, so make sure on that. If you need to instantly move a model, look into :SetPrimaryPartCFrame()

1 comment

0

MoveTo is a function of the Humanoid and Models.

Did you mean a moving platform?

local bp = Instance.new("BodyPosition")
local bg = Instance.new("BodyGyro")

bp.Parent = script.Parent
bg.Parent = script.Parent

local mainmodel = game.Workspace.mymodel
local platform = mainmodel.movingplatform --change platform location
local start = mainmodel.start --change start location
local finish = mainmodel.finish --change finish location
local bodypos = platform.BodyPosition
local pos1 = start.Position
local pos2 = finish.Position
local waittime=0.5

local currentpos = pos1
while wait(waittime) do --loop starts, you can remove it if you want to remove
	if currentpos == pos1 then
		currentpos = pos2
		wait (waittime)
		bodypos.Position = pos2
	else
		if currentpos == pos2 then
			currentpos = pos1
			wait(waittime)
			bodypos.Position = pos1
		end
	end
end --loop ends

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