Problem with CFrames

Hi there,

I’ve been working on a road plugin and it works pretty well for the most part, but when a road is curved, this happens:


Of course it should be easy to fix, just move them to the left, but I can’t figure out how to do that.

Here’s my code for the curve function:

if Input.KeyCode == Enum.KeyCode.Z then -- Curve Left
			if SelectedRoad:IsA("Part") then
				SelectedRoad.Orientation = Vector3.new(SelectedRoad.Orientation.X, SelectedRoad.Orientation.Y + GUI.Frame.RotValue.Text, SelectedRoad.Orientation.Z)
			else
				SelectedRoad:SetPrimaryPartCFrame(SelectedRoad.PrimaryPart.CFrame:ToWorldSpace(CFrame.Angles(0, math.rad(GUI.Frame.RotValue.Text), 0)))
			end
		end

SelectedRoad is the road that has been created and is being rotated

Regards,
First_Q

2 Likes

Are the lines in the middle of the road actually curved or straight? Having curved lines could make this a lot easier (if you don’t already).

1 Like

I use straight lines with small segments of road for sharp curves like so:

, because the length of these segments and the curve angle varies depending on the situation

1 Like