Rotate 90 Degrees

Hello.
I have a problem with my script, so I want to rotate a cilinder 90° degrees, the cilinder is behind of the character’s head and it should look like some clock behind them, but the problem is that I try to rotate it 90° degrees but it just seems to rotate a bit more or a bit less. Then I tried playing with the degrees and aumenting 0.01 in the math.deg() would make a drastical change. How do I fix this? Here is the code:

local function CreateClock(Character: Model?): Part
	local Part = Instance.new("Part")
	Part.Shape = Enum.PartType.Cylinder
	Part.CFrame = Character.PrimaryPart.CFrame * CFrame.new(0, 0, 1)
	Part.CFrame = Part.CFrame * CFrame.Angles(0, math.deg(90), 0) -- issue
	Part.Size = Vector3.new(0.05, 3.06, 3.06)
	Part.CanCollide = false
	Part.CastShadow = false
	Part.Color = Color3.fromRGB(255, 0, 0)
	Part.Name = "Clock"
	Part.Parent = Character.PrimaryPart
	return Part
end

return CreateClock

(Note that this creates and sets the position of the clock, the script that calls this module creates a WeldConstraint)
How it is:
RobloxScreenShot20240902_143907031

How I want it to be:
THIS

Your help would be REALLY appreciated, thanks.

1 Like

Instead of using math.deg try using math.rad and let me know what happens

3 Likes

Thank you VERY much! This worked! Why or How does this fix it? Thanks I REALLY needed this.

So for some reason CFrame.Angles will only accept radians (rad) for measurement, which means any non-zero value in CFrame.Angles must have math.rad(num) around it.

1 Like

Ohhh, thanks man, I REALLY hate CFrames, they have so much weird math…

Degrees are much easier to use that radians, but from what I know radians are are on a smaller scale which means they are more accurate, and they are used to measure angles. When you use math.rad your converting that number from degrees to radians, so in that way you always would see it in degrees. Try converting the number 90 to radians using math.rad youll see that the number is hard to work with and you wouldnt know it without using degrees first. (CFrames are so unnecessarily complicated)

1 Like

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