Model isnt moving to the correct position

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Move a model to a given position

  2. What is the issue? The part isnt moving to the correct position, The screenshot below shows the output from the script that moves the model. The Yellow is the model I’m trying to move, the gray part is the position it shows in the output (The spot i want it to go).

  1. What solutions have you tried so far? I’ve tried both MoveTo and PivotTo but neither made any difference.

The model does have a primary part, I’m not sure if I’ve set it wrong, Hirearchy of the model is below. Primary part circled. Parts in the screenshot can be seen in the screenshot above, they are the yellow parts.

image

Script that moves the part, The plot value being passed is an object. It prints the object correctly.

folder.Planting.OnServerEvent:Connect(function(plr, plant, plot)
	if plr.stats[plant].Value >= 1 then
		print(plr, plant, plot)
		local clone = folder.Seeds:FindFirstChild(plant):Clone()
		
		local newPosition = plot.Position + Vector3.new(0, 0.5, 0)
		clone:MoveTo(newPosition)

		print(newPosition)
		clone.Parent = plot
		clone:FindFirstChild("Growing").Value = true
		plr.stats[plant].Value -= 1
	end
end)

Edit: No errors, The spot that the model is at in the screenshot at the top is the default position of the model.

2 Likes

Don’t use :MoveTo(). It checks for collision and will automatically adjust the position to avoid clipping. This is likely the source of your problem. Use :PivotTo() with a CFrame instead.

3 Likes
local newPosition = plot.CFrame 
clone:PivotTo(plot.CFrame)

This is working, but I cant figure out how to add to the Y axis of the plot’s CFrame, I want to add 0.5 to it. The Documentation of CFrames is sort of confusing.

1 Like

An underrated feature from working with pivots is that you can set and store an offset to the model that’s automatically used when you call :PivotTo(). You can play around with these settings.

image

Otherwise, you can add offset just by adding the vector like you did before:

local newPosition = plot.CFrame + Vector3.new(0, .5, 0)
clone:PivotTo(plot.CFrame)
2 Likes

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