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

How would I randomly change the postion of a model?

How would i make a model spawn and randomly move it. I have this but you cant use Position on a model from what i know

while wait(3) do
	local pos1 = math.random(-256, 256)
	local pos2 = math.random(-256, 256)

	local drop = game.ReplicatedStorage.AirDrops.Drop
	drop:Clone().Parent = game.Workspace
	game.Workspace.Drop.Position = Vector3.new(pos1, 10, pos2)
end

1 answer

✓ Accepted answer

If Drop is a Model object, Models have a method called :MoveTo() which moves the whole object relative to it's primary part, if existent.

You can also use SetPrimaryPartCFrame on an object to move the primary part, and thus the whole object with it.

while wait(3) do
	local pos1 = math.random(-256, 256)
	local pos2 = math.random(-256, 256)

	local drop = game.ReplicatedStorage.AirDrops.Drop
	drop:Clone().Parent = game.Workspace
	game.Workspace.Drop:MoveTo(Vector3.new(pos1, 10, pos2))
end

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