I am trying to get the UpVector for a MeshPart to compare the directions with a base part after it has been rotated. However, I would always get -4.371138828673793e-08 as one of the values from the Vector if the Rotation of the part is not (0,0,0). I have tried to go around it in other ways but to no avail.
I could not find any forums that have discussed this issue before.
I did however learn that rotating the part by hand with the studio tools (Rotate Tool) does not break the issue when rotating the part; for example rotating it to (90,0,0) would output (0,0,1)
The Issue arises when I set the value by typing it in or setting the part’s cframe or rotation via script or commands; rotating it to (90,0,0) would output (0, -4.371138828673793e-08, 1) instead of the expected (0,1,0).
This is the code that I am using to test the Vectors after realizing it was not working. I can show the original script it is intended for if needed.
script.Parent.Changed:Connect(function()
print(script.Parent.CFrame.UpVector)
end)
Edit: Having the Value set to (0,0,0) would output (0,0,1)
I found a work around for it but it is chunky. I am not sure how I could trim it down or if there is a simpler way to do this. This is the code I made that works but look terrible.
local x,y,z
if -script.Parent.CFrame.UpVector.X == 1 or -script.Parent.CFrame.UpVector.X == -1 then
x = -script.Parent.CFrame.UpVector.X
else
x = 0
end
if -script.Parent.CFrame.UpVector.Y == 1 or -script.Parent.CFrame.UpVector.Y == -1 then
y = -script.Parent.CFrame.UpVector.Y
else
y = 0
end
if -script.Parent.CFrame.UpVector.Z == 1 or -script.Parent.CFrame.UpVector.Z == -1 then
z = -script.Parent.CFrame.UpVector.Z
else
z = 0
end