My model is moving underground when using PivotTo()

Im making a build system that consists in placing walls at the blueprint position, but sometimes the build ends up going underground for some reason

Screenshot by Lightshot – here is the wall model that im using, both wood wall and buildpos have Anchored and CanCollide set to true, and they belong to a collision group that only other buildings or players cannot trespass. The primary part of the model is the buildpos, which is located at the bottom of the wood wall model ( Screenshot by Lightshot )

i’ve tried playing around with collision groups, which didn’t seem to work at all

Screenshot by Lightshot – this is the blueprint object

and below is the code that builds a wall with the same position as blueprint model

local debounce = false

script.Parent.Build.Event:Connect(function(plr)
		if game.ServerStorage.buildings:FindFirstChild(script.Parent.build.Value) then
			local item = game.ServerStorage.buildings[script.Parent.build.Value]:Clone()
			item.Parent = workspace.Buildings
			item:PivotTo(script.Parent.CFrame)
			item[script.Parent.build.Value].Orientation = Vector3.new(0,0,-90)
			item[script.Parent.build.Value].CollisionGroup = "Default"
			item.Builder.Value = plr.UserId
		end
		script.Parent:Destroy()
end)

Anyone’s got any idea as to why this is happening? (the script.Parent.build.Value is equal to “wood wall”)

You probably need to edit the “Pivot Offset” property of the model to set the pivot point at the bottom of the model.
Or when placing it you could do the math to call pivotTo on a CFrame that is raised by half of the models extentSize.

1 Like

This seemed to do the trick, thank you very much! ( doin the math)