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?
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?
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)
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
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