I have recently come across an issue with a door script: Due to the fact that Pi is rounded slightly, my entire code doesn’t work, as everything is slightly off. The problem with this is that I can’t set the orientation of a primary part without it, or if I can, it is very difficult. My code requires exact numbers, and so this causes some issues.
local function open() lookVector = primaryPart.CFrame.LookVector repeat y = math.rad(primaryPart.Orientation.Y - 90) nextCFrame = CFrame.new(primaryPart.Position) * CFrame.Angles(0, y, 0) group:SetPrimaryPartCFrame(nextCFrame) print(primaryPart.CFrame.LookVector) wait(0.5) until primaryPart.CFrame.LookVector == Vector3.new(lookVector.Z - lookVector.Z * 2, -0, lookVector.X) isOpen = true end
Basically, I need to either remove the radians entirely, or find a way to make them more precise.
math.cleil() do not work, as I have tried them.
The reason that it turns 90 degrees at a time is for testing reasons. Same with the 0.5 second delay.
Don’t question the -0, as that’s just what Roblox thinks that 0 is for some reason. It affects nothing, as it is the y lookVector, and I don’t want my door to open like a garage door.