Car align orientation problem

when i hold my W key to rotate my car forward and A to rotate it left as well, they work fine together but if i use a different key combination like W and D right afterwards, instead of it rotating to the other side the alignorientation for the left/right goes back to normal so the car is only tilted forward instead of tilting forward and to the right. ty for the help!!

(yes im aware of the if statements, i was trying something earlier)

local frontBackTilt = 10
local leftRightTilt = 15

local function applyTilt()
	local align_orientation = zalek.PrimaryPart.AlignOrientation
	local clampedrotation = math.clamp(-frontBackTilt, math.rad(-frontBackTilt), 0)
	local orientation = zalek.PrimaryPart.CFrame * CFrame.Angles(0,0,clampedrotation)
	align_orientation.CFrame = orientation
end

local function applyLeftTilt()
	local align_orientation = zalek.PrimaryPart.AlignOrientation
	local clampedrotation = math.clamp(-leftRightTilt, math.rad(-leftRightTilt), 0)
	local orientation = zalek.PrimaryPart.CFrame * CFrame.Angles(clampedrotation,0,0)
	align_orientation.CFrame = orientation
end

local function applyRightTilt()
	local align_orientation = zalek.PrimaryPart.AlignOrientation
	local clampedrotation = math.clamp(leftRightTilt, 0, math.rad(leftRightTilt))
	local orientation = zalek.PrimaryPart.CFrame * CFrame.Angles(clampedrotation,0,0)
	align_orientation.CFrame = orientation
end

local function applyReverseTilt()
	local align_orientation = zalek.PrimaryPart.AlignOrientation
	local clampedrotation = math.clamp(frontBackTilt, 0, math.rad(frontBackTilt))
	local orientation = zalek.PrimaryPart.CFrame * CFrame.Angles(0,0,clampedrotation)
	align_orientation.CFrame = orientation
end

local function resetTilt()
	local align_orientation = zalek.PrimaryPart.AlignOrientation
	align_orientation.CFrame = CFrame.Angles(0,0,0)
end

local function tilt_car(p, action_name)
	if action_name == "fly_forward" then
		applyTilt()
	end
	if action_name == "stop_fly_forward" then
		resetTilt()
	end
	if action_name == "fly_backwards" then
		applyReverseTilt()
	end
	if action_name == "stop_fly_backwards" then
		resetTilt()
	end
	if action_name == "fly_left" then
		applyLeftTilt()
	end
	if action_name == "stop_fly_left" then
		resetTilt()
	end
	if action_name == "fly_right" then
		applyRightTilt()
	end
	if action_name == "stop_fly_right" then
		resetTilt()
	end
end
keys_event.OnServerEvent:Connect(tilt_car)

i made a video for better visualisation:

1 Like