How can I move a whole model to a specific position

I have a car model which contains more than one primary part, i tried to set a primary part to the model but it just moves the “paint”. I want to move the whole car to the desired spawn position but i don’t know how. I thought about creating a part and making everything in the car a child to that part but it still doesn’t work…

local function spawnCar()
	local car = chooseCar()
	
	for i, v in pairs(Spawnables:GetChildren()) do
		if v.Name == car then
			local clone = v:Clone()
			local carInfoClone = carInfo:Clone()
			clone.Parent = workspace.SpawnedCars
			clone.PrimaryPart.Position = Vector3.new(workspace.Area:FindFirstChild("Road Spawn").Position.X, workspace.Area:FindFirstChild("Road Spawn").Position.Y, workspace.Area:FindFirstChild("Road Spawn").Position.Z	) -- here is where i set the cars position
			
			carInfoClone.Parent = clone
			carInfoClone:FindFirstChild("MainFrame").CarName.Text = clone.Name
			carInfoClone:FindFirstChild("MainFrame").CarPrice.Text = "$"..tostring(clone:FindFirstChild("CarStats"):FindFirstChild("Price").Value)
			carInfoClone:FindFirstChild("MainFrame").CarRarity.Text = tostring(clone:FindFirstChild("CarStats"):FindFirstChild("Rarity").Value)
		end
	end
end

while wait(SpawnTime) do
	spawnCar()
end

Try using PVInstance:PivotTo(CFrame : CFrame). A PVInstance is anything physically rendered, like Models or BaseParts (parts, meshes, etc). PivotTo will move the entire model, using its Pivot as the focal point. The pivot is often the PrimaryPart, but if none exists, it’s the middle of all combined parts, so an averaged center.

Example:

local function spawnCar()
	local car = chooseCar()
	
	for i, v in pairs(Spawnables:GetChildren()) do
		if v.Name == car then
			local clone = v:Clone()
			local carInfoClone = carInfo:Clone()
			clone.Parent = workspace.SpawnedCars
            local newCF = CFrame.new(Vector3.new(workspace.Area:FindFirstChild("Road Spawn").Position.X, workspace.Area:FindFirstChild("Road Spawn").Position.Y, workspace.Area:FindFirstChild("Road Spawn").Position.Z	))
			
            clone:PivotTo(newCF) -- clone will move here
			
			carInfoClone.Parent = clone
			carInfoClone:FindFirstChild("MainFrame").CarName.Text = clone.Name
			carInfoClone:FindFirstChild("MainFrame").CarPrice.Text = "$"..tostring(clone:FindFirstChild("CarStats"):FindFirstChild("Price").Value)
			carInfoClone:FindFirstChild("MainFrame").CarRarity.Text = tostring(clone:FindFirstChild("CarStats"):FindFirstChild("Rarity").Value)
		end
	end
end

while wait(SpawnTime) do
	spawnCar()
end
1 Like

and what if I want to change its orientation, it spawns backwards

Multiply the CFrame you provide by whatever orientation you want with CFrame.Angles

Alternatively, just use workspace:FindFirstChild("Road Spawn").CFrame as your PivotTo destination

1 Like

Thanks for helping me, much appreciated!!

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