Model not moving to correct position

I am trying to create a script that clones models and places them 2000 studs apart. I have done this with partial success, however the Y axis is for lack of a better term, going insane.

When I set the Y axis of the second vector3 in the :MoveTo line, the model moves 3 studs up instead of down. The properties become more bizarre the closer I move the model to Y axis: 0. I’ve figured out that the model is moving in this weird way because of car spawners that I have placed close to the models. When I move the car spawners away from the model, the model behaves as intended.

I have no idea what could be causing this, but I suspect it has something to do with the cars already in Workspace somehow affecting the model being placed. If someone could explain to me what this error is and how it could be fixed, I would greatly appreciate it.

local RoadsTo = game.Workspace.World.Road
local RoadsFrom = game.ReplicatedStorage.Roads
local Pos = RoadsTo.Pos

local Parts = {}

for i,v in RoadsFrom:GetChildren() do
	if v:IsA("Model") then
		table.insert(Parts,v.Name)
	end
end

for i = 0,13 do -- 14 * 2000 = 26k
	print(i)
	local rand = math.random(1,#Parts)
	local clone = RoadsFrom[Parts[rand]]:Clone()
	clone.Name = tostring(i)
	clone.Parent = RoadsTo
	clone:MoveTo(Vector3.new(-1075,-1,0) + Vector3.new(-2000*i, 0 , 0)) -- u have to move model after setting parent idk why
end

:MoveTo() places the model at the supplied position, BUT moves it up as far is required in order for the model not to be clipping with anything.

Have a look at :PivotTo() instead. It allows you to move the model, but doesn’t force the model up to prevent clipping.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.