CFrame rotation problem in city generation code

if neighbour ~= nil then
	if direction == 1 then
		newChunk:WaitForChild("chunkModel0"):PivotTo(newChunk:WaitForChild("chunkModel0").PrimaryPart.CFrame()*CFrame.Angles(0,math.rad(neighbour.Parent.Parent.node.Orientation.Y),0) * CFrame.Angles(0, math.rad(0),0))
	elseif direction == 2 then
		newChunk:WaitForChild("chunkModel0"):PivotTo(newChunk:WaitForChild("chunkModel0").PrimaryPart.CFrame()*CFrame.Angles(0,math.rad(neighbour.Parent.Parent.node.Orientation.Y),0) * CFrame.Angles(0, math.rad(90),0))
	elseif direction == 3 then
		newChunk:WaitForChild("chunkModel0"):PivotTo(newChunk:WaitForChild("chunkModel0").PrimaryPart.CFrame()*CFrame.Angles(0,math.rad(neighbour.Parent.Parent.node.Orientation.Y),0) * CFrame.Angles(0, math.rad(180),0))
	elseif direction == 4 then
		newChunk:WaitForChild("chunkModel0"):PivotTo(newChunk:WaitForChild("chunkModel0").PrimaryPart.CFrame()*CFrame.Angles(0,math.rad(neighbour.Parent.Parent.node.Orientation.Y),0) * CFrame.Angles(0, math.rad(270),0))
	end
end

hello this is a piece of code for my city generation system, but somehow its still giving a error, could someone tell me how to do this properly?

2 Likes

The error:
“Workspace.cityGenHandler:227: attempt to call a CFrame value - cityGenHandler:227”

2 Likes

WaitForChild("chunkModel0").PrimaryPart.CFrame()

Remove the parantheses

3 Likes

I know the solution is solved and all but the way you coded this is kinda peeving me, can’t you just multiply the Y rotation in angles by doing (direction - 1) * 90? You’re writing 4 if statements that are redundant.

4 Likes

Oh that makes sense thanks aswell!

3 Likes

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