How to get a models X,Y,Z separately

I need to get a models X,Y,Z respectively. I tried using :GetPivot() but it just gave me a long list of numbers.

local cframeValue = modelHere:GetPivot()
local x = cframeValue.Position.X
local y = cframeValue.Position.Y
local z = cframeValue.Position.Z
1 Like

does not work the values remain the same

Can you explain what you mean by that? Are the variables being set to the same number for you?

2 Likes

yes, the numbers remain the same

x,y,z are being printed as the same number even though i did



local train = script.Parent


while true do
	local cframeValue = train:GetPivot()
	local x = cframeValue.Position.X
	local y = cframeValue.Position.Y
	local z = cframeValue.Position.Z
	print(x)
	print(y)
	print(z)
	wait()
end



1 Like

do you have any solutions to fix this problem?

1 Like

It seems if you don’t correctly change the model’s position, it might result in incorrect position values.


Sorry for the delayed reply, I was recording the video :slight_smile:

As you can see the model’s pivot can be a bit inaccurate depending on the way you change the model’s position for some reason?

EDIT: This is because the WorldPivot property will not be based on the model’s children position if you do not have a PrimaryPart.

Thanks for the effort. I guess instead of using the models position, i will use a part in the model instead

You can also just make sure to use PivotTo() as I think that will correctly change the model’s position.

is there a way to get a models x,y,z however

It seems that this is intended behavior, you can just set a PrimaryPart and the pivot will follow that, from there you can just refer to @Pokemoncraft5290’s post.

You can set the Model.PrimaryPart to any part to any part of the model, I would recommend for you to set to the part that is in the “center” of your model.

2 Likes

ah ok, lemme do this. Thanks for the suggestion

1 Like

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