MoveTo not working

  1. What do you want to achieve?

I’m trying to spawn models and parts for my arcade dropper game as obstacles for when they drop a ball to get a score.

  1. What is the issue?

When I try to set the position(Use MoveTo) for obstacles that are models, nothing happens. It sets rotation and CFrame but it doesn’t work using MoveTo.
Example showing what happens every time I try to spawn models:

Entire Obstacles Module
local ServerStorage = game:GetService("ServerStorage")
local Debris = game:GetService("Debris")
local Obstacles = {}

function Obstacles.Spawn(number)
	for i = 1,number do
		local randomObstacle = math.random(1,#ServerStorage.Spawns:GetChildren())
		local chosenObstacle = ServerStorage.Spawns:GetChildren()[randomObstacle]:Clone()
		
		local arcade = workspace.Arcade
		local slider = arcade.Spawn
		
		local X = math.random(-slider.Size.X/2,slider.Size.X/2)
		local Y = math.random(-slider.Size.Y/2,slider.Size.Y/2)
		local Z = math.random(-slider.Size.Z/2,slider.Size.Z/2)
		
		if chosenObstacle:IsA("BasePart") then
			chosenObstacle.CFrame = slider.CFrame
			chosenObstacle.Position = chosenObstacle.Position + Vector3.new(X,Y,Z)
		elseif chosenObstacle:IsA("Model") then
			
			local randoms = {
				CFrame.Angles(0,math.rad(90),0),
				CFrame.Angles(0,math.rad(-90),0)
			}
			
			local random = math.random(1,#randoms)
			local chosen = randoms[random]
			
			chosenObstacle:PivotTo(slider.CFrame * chosen)
			chosenObstacle:MoveTo(chosenObstacle.PrimaryPart.Position + Vector3.new(X,Y,Z))
		end
		chosenObstacle.Parent = arcade.Obstacles
	end
end

function Obstacles:Change(number)
	for _,obstacle in workspace.Arcade.Obstacles:GetChildren() do
		if obstacle then
			Debris:AddItem(obstacle,.1)
		end
	end
	self.Spawn(number)
end

return Obstacles

Tweak some of it …
Hard to be sure without a way to test it.

local ServerStorage = game:GetService("ServerStorage")
local Debris = game:GetService("Debris")
local Obstacles = {}

function Obstacles.Spawn(number)
	for i = 1, number do
		local randomObstacle = math.random(1, #ServerStorage.Spawns:GetChildren())
		local chosenObstacle = ServerStorage.Spawns:GetChildren()[randomObstacle]:Clone()
		
		local arcade = workspace.Arcade
		local slider = arcade.Spawn
		
		local X = math.random(-slider.Size.X/2, slider.Size.X/2)
		local Y = math.random(-slider.Size.Y/2, slider.Size.Y/2)
		local Z = math.random(-slider.Size.Z/2, slider.Size.Z/2)
		
		if chosenObstacle:IsA("BasePart") then
			chosenObstacle.CFrame = slider.CFrame
			chosenObstacle.Position = chosenObstacle.Position + Vector3.new(X, Y, Z)
		elseif chosenObstacle:IsA("Model") then
			local randoms = {
				CFrame.Angles(0, math.rad(90), 0),
				CFrame.Angles(0, math.rad(-90), 0)
			}
			local random = math.random(1, #randoms)
			local chosen = randoms[random]
			chosenObstacle:SetPrimaryPartCFrame(slider.CFrame * chosen)
			chosenObstacle:SetPrimaryPartCFrame(chosenObstacle.PrimaryPart.CFrame + Vector3.new(X, Y, Z))
		end
		chosenObstacle.Parent = arcade.Obstacles
	end
end

function Obstacles:Change(number)
	for _, obstacle in ipairs(workspace.Arcade.Obstacles:GetChildren()) do
		if obstacle then
			Debris:AddItem(obstacle, 0.1)
		end
	end
	self.Spawn(number)
end

return Obstacles

I would rather not use setprimarypartcframe because its deprecated. I want to actually find out why this is happening.

It does work though with setprimarypartcframe.

I also tried:

chosenObstacle:PivotTo(slider.CFrame * chosen + Vector3.new(X,Y,Z))

and it works but I still don’t understand how MoveTo does not work.

If it works with SetPrimaryPart then the problem with your 1st script may be a PrimaryPart not set correctly, manually.

I set a primary part for my spawn model, the setprimarypartcframe also worked.

SetPrimaryPartCFrame doesn’t work if there isn’t a PrimaryPart.

really guessing now

local ServerStorage = game:GetService("ServerStorage")
local Debris = game:GetService("Debris")
local Obstacles = {}

function Obstacles.Spawn(number)
    for i = 1, number do
        local randomObstacle = math.random(1, #ServerStorage.Spawns:GetChildren())
        local chosenObstacle = ServerStorage.Spawns:GetChildren()[randomObstacle]:Clone()
        
        local arcade = workspace.Arcade
        local slider = arcade.Spawn
        
        local X = math.random(-slider.Size.X/2, slider.Size.X/2)
        local Y = math.random(-slider.Size.Y/2, slider.Size.Y/2)
        local Z = math.random(-slider.Size.Z/2, slider.Size.Z/2)
        
        if chosenObstacle:IsA("BasePart") then
            chosenObstacle.CFrame = slider.CFrame * CFrame.new(X, Y, Z)
        elseif chosenObstacle:IsA("Model") then
            local randoms = {
                CFrame.Angles(0, math.rad(90), 0),
                CFrame.Angles(0, math.rad(-90), 0)
            }
            local random = math.random(1, #randoms)
            local chosen = randoms[random]
            chosenObstacle.CFrame = slider.CFrame * chosen * CFrame.new(X, Y, Z)
        end
        chosenObstacle.Parent = arcade.Obstacles
    end
end

function Obstacles:Change(number)
    for _, obstacle in ipairs(workspace.Arcade.Obstacles:GetChildren()) do
        if obstacle then
            Debris:AddItem(obstacle, 0.1)
        end
    end
    self.Spawn(number)
end

return Obstacles

Models don’t have a CFrame value.

welp … you can put a part in model … set the primary to the part.
Then control the model or the primary part.
Guess i need to find a new way to avoid setprimarypartcframe