:PivotTo() not working great

Hello, Im trying to make a system where players can equip different stands they have in their inventory and then it will clone it from replicated storage and move it to where their old stand was. Someone recommended I use GetPivot() and PivotTo() in a previous post. This works… somewhat, the orientation is off and its in the ground a little. Any ideas on how I could fix this?

image

image

1 Like

Im assuming the pivot of the old stand and the new stand are off, causing it to rotate incorrectly and clip into the ground, try making the pivot’s of each stand the same, then it should “:PivotTo()” correctly.

2 Likes

Can you show the whole script? I don’t quite understand it yet

2 Likes

to make a complete 180 turn, you to rotate it as pi radians, or simply pi, the Y Axis should rotate it and Left to Right, so you can tell the Y Axis to rotate using math.pi

As for it sticking in the Ground, Increment a small amount, or raycast to find the surface of the Floor.

I cant do that since there’s 12 different stands with their own positions.

ChangeStandEvent.OnServerEvent:Connect(function(player, Owned, OldStand, stand)
	local StandNum = game.Workspace.Stands:FindFirstChild(Owned)
	local OldStand = StandNum:FindFirstChild(StandNum.EquippedStand.Value) -- old stand
	local NewStand = game.ReplicatedStorage.Assets.Stands:FindFirstChild(stand) -- new stand
	local OldStandPivot = OldStand:GetPivot() -- cframe both holds position and orientation
	local userID = player.UserId
	
	player.MiscStats.EquippedStand.Value = stand

	OldStand:Destroy()
	local Clone = NewStand:Clone()
	Clone:PivotTo(OldStandPivot)
	Clone.Parent = StandNum

	local ScrollingFrame = Clone.StandButtons.UI.ScrollingFrame
	AssetManager:GetAssets(player.Name, userID, ScrollingFrame)

	local OwnerLabel = Clone.SignDescription.SurfaceGui.Frame.OwnerLabel
	OwnerLabel.Text = player.Name.."'s Stand"
	OwnerLabel.Parent.MoneyRaised.Text = player.leaderstats.Raised.Value .. "$ Raised"

	print('Changed Stand')
end)

So you’re trying to duplicate the NewStand and put it in the CFrame of the old stand?

My first suggestion is to make sure they both have the same orientation. Basically, your first Old stands orientation could be different from the New stand despite having the same SET orientation. This part really comes down to editing the orientation of the parts inside the model.

Let me know if you don’t really understand this.

The problem is because the ‘offset’ of the old stand and the new stand are different
Pivot To will place them by their offset position and origin.

Edit: I see @KingBlueDash already gave the correct answer.

I tried putting the stand Im trying to clone in workspace and setting its orientation to the same as the original stand seems to work fine when I do that so I’m not really sure.

Try setting an invisible primary part in which all stands are on top of. Use this as a sort of template/base to make sure all stands look and pivot the same way.

3 Likes

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