Models' Pivot points seem to be at random locations?

Hey. This is a very annoying issue, where models’ pivot points seem to be in random locations. Without having to necessarily go through every model and reset the pivot points manually, or use a script to try and reset every individual one for each model retrospectively, is there a quicker way of resetting pivots in studio, or am I missing something here?

I’ve tried using the “Reset” button when no models are selected in general and whenever I click on a specific model that produces this issue, it doesn’t automatically reset the pivots for all models, unless I manually select them all one by one AND then click the “Reset” button which I don’t want to waste my time doing because that’s unproductive.

image

Basically, the whole point of this topic is asking if they is a method to just reset the pivots for all models, regardless of the ones which don’t produce the issues or not. Then I won’t have to manually go through every model to reset their pivot points unless that is the only solution. Am I missing something here? And yes, I’ve tried pressing Ctrl+L and have restarted studio to no avail. Is there a quick fix to this that I may have missed? Assistance is appreciated.

Hi @Herbz_Dev2106

i made command bar script that resets pivot of all models in workspace.

Keep in mind it will be laggy if you have a lot of models.
Also you can undo if you made a mistake.

This script will only work if you ran in command bar.

local ChangeHistoryService = game:GetService("ChangeHistoryService")

function ResetPivot()

	for _,Model in pairs(workspace:GetDescendants()) do
		if Model:IsA("Model") then
			local NewModel = Instance.new("Model")
			NewModel.Name = Model.Name
			NewModel.PrimaryPart = Model.PrimaryPart
			NewModel.Parent = Model.Parent

			for _,Child in pairs(Model:GetChildren()) do
				Child.Parent = NewModel
			end

			Model.Parent = nil
		end
	end

	ChangeHistoryService:SetWaypoint("ResetPivot")
end

ResetPivot()
1 Like

I’ve tried this in the command bar with a model’s pivot deliberately misaligned and it stays the same. It’s a part inside a model placed directly within the Workspace.

Did this code work for you? Maybe I am doing something wrong.

Do you have a PrimaryPart set in every one of the models?

1 Like

No. Aside from that, this might sound a little confusing but for example, if I have a model within a model that is inside of a model, when I select the main model the pivot is in the right place, but when I select individual models within the same main model for example, it has strange pivot locations that I can’t seem to clear unless I go through each and every one of them manually.

Now I’m not sure if that has something to do with it, but none of the less I can’t just simply reset the pivots unless I reset every model manually, and so far getting such scripts to do the automatic process has so far not sufficed or worked, even when they don’t produce any errors.

HOWEVER, I’ve just figured another potential solution is maybe just resetting the pivots for the models containing the objects with the strange pivot locations, rather than trying to reset the pivots for all the objects inside the model individually. My theory is if I reset the pivots of the main models then it will automatically reset any pivots of objects located within the same model that’s pivot is being reset.

Did that answer your question @Scottifly?


Edit:

Right, I have removed most of the problem by resetting the pivots of the main models but that alone doesn’t seem to reset any objects’ pivots located inside the same model. However, I no longer seem to encounter any issues with the pivots although I may mark this post as solved if I can confirm this fully. Feel free if anybody else has any different ideas that might be a more fool-proof solution that the one I just suggested, or else I will likely consider marking this post as solved if no alternative solution is found.

PivotPoints do not update unless if it was updated manually by hand or script or if a primary part is assigned it’ll follow that.

1 Like

Yeah I think I must have cloned something somewhere for the pivots to become misaligned.


Update:

I’m now in a situation where I’ve been able to reset the main models’ pivots manually that were originally misaligned, but not any other potential objects within them, since @xcreatee’s solution didn’t seem to work for me either. Simply fixing the main models’ pivots doesn’t account for the fact that there may be more less noticeably hidden objects, whose pivots’ I cannot ascertain without looking through every potential model manually.

For this reason, this would only be a partially solved solution to my problem, not a fully fool-proof one. This was just my original idea by the way. (For example, I’ve just discovered another model in which the pivot wasn’t reset like the other models encapsulating it were). That is the point I am trying to make here.

I’m guessing the script needs an existing PrimaryPart to work or is that not the case? Since most of the pivot misalignments are from models that don’t have a designated PrimaryPart. Either way I execute the script and it doesn’t seem to change anything; at least for me.

If model’s primary part doesn’t matter to you can comment this part
or just erase that.

If it does matter don’t do that.

NewModel.PrimaryPart = Model.PrimaryPart

script without setting PrimaryPart:

local ChangeHistoryService = game:GetService("ChangeHistoryService")

function ResetPivot()

	for _,Model in pairs(workspace:GetDescendants()) do
		if Model:IsA("Model") then
			local NewModel = Instance.new("Model")
			NewModel.Name = Model.Name
			NewModel.Parent = Model.Parent

			for _,Child in pairs(Model:GetChildren()) do
				Child.Parent = NewModel
			end

			Model.Parent = nil
		end
	end

	ChangeHistoryService:SetWaypoint("ResetPivot")
end

ResetPivot()
1 Like

It worked for me the first time, but for some reason didn’t work for me the second time when another part was added after execution? Since when I executed the same code for the 2nd time, it didn’t reset the pivot alignment of the new part for some reason.


Here is what I mean:

1st Part:

2nd Part:

Is there any error messages, for me it only worked when model doesn’t have primary part because it will always pivot point to origin of PrimaryPart?

Also is it that model only one part or have other descendants?

Yes I get an error message on this game. However, when I try it on a blank baseplate game it works without the error message being displayed:

image

And yes, the game contains models with other descendants, yes. But as far as I know of without checking every model, none of the models have a PrimaryPart set other than unrelated ones on the same game.

Error is when you try to parent humanoid to other character it will cause error due objects whose Parent property cannot be changed during runtime or in Studio scripting. This usually happens with objects that are managed by the engine or special internal systems, like certain instances in Humanoid, Status, Terrain, SoundService, etc.

Now should work:

local ChangeHistoryService = game:GetService("ChangeHistoryService")

function ResetPivot()

	for _,Model in pairs(workspace:GetDescendants()) do
		if Model:IsA("Model") then
			
			if Model:FindFirstChildOfClass("Humanoid") then return end

			local NewModel = Instance.new("Model")
			NewModel.Name = Model.Name
			NewModel.Parent = Model.Parent

			for _,Child in pairs(Model:GetChildren()) do
				Child.Parent = NewModel
			end

			Model.Parent = nil


		end
	end

	ChangeHistoryService:SetWaypoint("ResetPivot")
end

ResetPivot()

This time it doesn’t print any error messages, yet it doesn’t do anything either. I’ve tried on a blank baseplate and it still works, just not on the game. Maybe because there are more models?

Game:

Blank Baseplate:


Idk, I don’t know of any objects in the explorer that are part of Humanoid or Terrain in the game other than just simply lots of models, which include both those which are related to the pivot problem and those that are unrelated.

Sorry to hear script doesn’t work as you excpected, but my script doesn’t calculate pivot,its roblox’s engine that calculate due creating new model,Engine has two option to calculate:

  1. When you have primary part setted in model,Engine setts pivot to its origin
  2. If your model doesn’t have primary part setted in model it calculate into center point of all baseparts inside of model i think on X axis you have another part inside your model.