VectorToWorldSpace: keeps returning the same result no matter the rotation

I was trying to get the “length” of a part, with “length” being X Y or Z values depending on the rotation and the world (with Z world axis in this example). I believe that my function worked fine until specific moment. I don’t know what exactly changed. The part is only rotated by 90 degrees. Anybody has an idea how to possibly fix it or find another way to get “length” of the part?


This is my code

2 Likes

could you elaborate? i don’t quite understand what you are trying to do. what is the context in which you would use this, and what exact value are you trying to get when you say ‘length’ of the part? Are you referring to the longest side or a specific dimension in world space? Also what isn’t working in it anymore? What value are you expecting, and what value are you getting?

1 Like

Let’s say I have a world space. I want to get “length” of the part, which would be the size.something property. That “something” changes when the part is rotated. If I were to take a regular part in roblox studio, which has 0, 0, 0 orientation, the “length” would be equal to size.Z property. However, if I rotate the part by 90 degree on the Y axis, the same “length” property would no longer be size.Z but size.X instead.

This is what I am trying to accomplish: Get the size vector relevant to the world orientation, so, the part with for example orientation of 0, 90, 0 would give the result of 4, 1, 2. If I just use the size property, the result is 2, 1, 4.

If i understand you correctly, your original code should work fine. Are you sure your issue is with calculating it? Although you can try this, i believe your issue isn’t with this.

local button = script.Parent.Parent

script.Parent.MouseClick:Connect(function()
	local cframe = button.CFrame
	local size = button.Size

	local absoluteSize = Vector3.new(math.abs(cframe.RightVector:Dot(size)), math.abs(cframe.UpVector:Dot(size)), math.abs(cframe.LookVector:Dot(size)))
	print(absoluteSize)
end)

Sorry for the late reply, but it seems that your code does not seem to work either. It still gives the same result no matter the rotation


Weird, could you send me the place you are testing it in?

What do you mean by “Send me the place”?

File → Download a Copy, considering it’s a new baseplate that doesn’t include any personal information from your game

Alright, will be there right away

you want object space not world space

Same code but object space? Right?

yeah the code is fine but once you change the vector in object space you have to convert it back to world space when setting part size / position afterwards


Still same output lol

the length of a part is Z in object space

Yeah, but I the problem is, when part is rotated, that length is no longer Z, but X.

it’s always Z in object space no matter the rotation

I want the length in world space. But there is not yet a solution

I haven’t changed anything in your game, just loaded it up, could you send a vid of what you are trying to do?

1 Like

I can’t record a video. But I can tell you that I do everything the same way as you do, and yet it just refuses to work… I might actually just come up with another solution for my problem instead of using VectorToWorldSpace method

originCFrame:ToWorldSpace(originCFrame:ToObjectSpace(originCFrame) + button.Size);