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 move a Model using scripts?

Alright, so I'm trying to move models around for my game. But when I try to move a model, I get an error. Here are the things I tried:

local pineTree = workspace.PineTree

pineTree.Position = Vector3.new(10, 10, 10)

On this code above, it says that Position is not a valid member of the Model; this means the script is trying to find a child named "Position" and since it didn't find the child with that name, it gives me an error.

local pineTree = workspace.PineTree

for i, v in ipairs(pineTree:GetChildren()) do
	if v:IsA("Part") then
		v.Position = Vector3.new(10, 10, 10)
	end
	wait()
end

On this code above, it can move the parts; but not the correct way. It puts all parts in 1 place, and it looks bad. Here is what it looks like: Link. So in conclusion, the 2 ways I've tried doesn't work, and I want to know how to move a model using scripts like this.

1 answer

✓ Accepted answer

If you want to move a model through a script you could use [Modelname]:MoveTo(Vector3.new(position))

Example:

--ServerScript in workspace
local model = workspace:WaitForChild('Drooling Zombie') --Our model
model:MoveTo(Vector3.new(31.4, 0.5, -32.8)) --New position

1 comment

0

ok thanks man

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