MoveTo not working correctly

  1. What do you want to achieve? Keep it simple and clear!
    Trying to make a part that will spawn model

  2. What is the issue? Include screenshots / videos if possible!
    The model that spawn is not spawning correctly the position is wrong

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried searching for solution but found none

local Storage = game:GetService("ServerStorage")
local Box = Storage:WaitForChild("Breakables").Box2
local boxclone = Box:Clone()
boxclone.Parent = script.Parent.Parent.Part
boxclone:MoveTo(script.Parent.Position)

local deb = false

while true do
	local child = script.Parent.Parent.Part:GetChildren()
	if #child >= 0 and deb == false then
		deb = true
		wait(10)
		local clone = Box:Clone()
		clone:MoveTo(script.Parent.Position)
		deb = false
	end
end

The model suppose to spawn at the red glowing node

:MoveTo() finds a proper spot, where it doesn’t collides with any part.
So if you move it in the middle of a part, it’s going to put it on top.

Use :SetPrimaryPartCFrame() instead

Basically:

  • MoveTo() relies on part collisions, as it tries to find the next best non-collision area possible

  • SetPrimaryPartCFrame() doesn’t, this is probably what you want more but you’ll have to set a PrimaryPart for the Box first & this is a CFrame value

local Storage = game:GetService("ServerStorage")
local Box = Storage:WaitForChild("Breakables").Box2
local boxclone = Box:Clone()
boxclone.Parent = script.Parent.Parent.Part
boxclone:SetPrimaryPartCFrame(CFrame.new(script.Parent.Position))

local deb = false

while true do
	local child = script.Parent.Parent.Part:GetChildren()
	if #child >= 0 and deb == false then
		deb = true
		wait(10)
		local clone = Box:Clone()
		clone:SetPrimaryPartCFrame(CFrame.new(script.Parent.Position))
		deb = false
	end
end