CFrame orientation not rotating to exact orientation

In the script its rotating 90 degree and it prints out the number correctly but inside of a game its not rotating to that exact orientation?

--//Services//--
local ServerStorage = game:GetService("ServerStorage")

--//Generator//--
local currentAnchorHeight = 0
local currentOrientation = 0

while task.wait(2) do
	print("hi")
	local totalSections = #ServerStorage.Sections:GetChildren()
	local randomSectionIndex = math.random(1, totalSections)
	local clonedSection = ServerStorage.Sections:GetChildren()[randomSectionIndex]:Clone()
	clonedSection:SetPrimaryPartCFrame(CFrame.new(0, currentAnchorHeight, 0)*CFrame.fromOrientation(0,currentOrientation,0))
	clonedSection.Parent = workspace.Tower
	currentAnchorHeight = currentAnchorHeight + 16
	currentOrientation = currentOrientation + 90
	print(currentOrientation)
end

Make sure to work in radians with CFrame and use math.rad or math.pi/2

3 Likes

you need to convert the degrees to radiants using math.rad(degrees), as CFrames work with radiants. Or use math.pi/2 (equivalent to a quarter circle in radiants), mentioned by @dthecoolest.

CFrame.fromOrientation(0,math.rad(currentOrientation),0)
2 Likes

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