i have an alignorientation instance in my car to tilt my car when i press keys like W, A, S, D. if im holding W and A or W and D and i release D, it will reset my car rotation back to 0. i want it so that if i’m holding W and D together and i release D, it will only reset my right rotation to 0 and keep the from rotation for W. hopefully that makes sense. thx!!
client:
local function handle_keybinds(inp:InputObject, gameproc)
if gameproc then return end
local occupant = zalek_data.seats.control_seat.Occupant
if inp.UserInputType == Enum.UserInputType.Keyboard then
if occupant then
local plr_occ = game.Players:GetPlayerFromCharacter(occupant.Parent)
if plr_occ then
if inp.KeyCode == zalek_data.controls.headlights then
keys_event:FireServer("headlights")
elseif inp.KeyCode == zalek_data.controls.fly_forward then
keys_event:FireServer("fly_forward")
elseif inp.KeyCode == zalek_data.controls.fly_backwards then
keys_event:FireServer("fly_backwards")
elseif inp.KeyCode == zalek_data.controls.fly_left then
keys_event:FireServer("fly_left")
elseif inp.KeyCode == zalek_data.controls.fly_right then
keys_event:FireServer("fly_right")
end
end
end
end
end
uis.InputBegan:Connect(handle_keybinds)
local function handle_keybindsEnded(inp, gameproc)
if gameproc then return end
local occupant = zalek_data.seats.control_seat.Occupant
if inp.UserInputType == Enum.UserInputType.Keyboard then
if occupant then
local plr_occ = game.Players:GetPlayerFromCharacter(occupant.Parent)
if plr_occ then
if inp.KeyCode == zalek_data.controls.fly_forward then
keys_event:FireServer("stop_fly_forward")
elseif inp.KeyCode == zalek_data.controls.fly_backwards then
keys_event:FireServer("stop_fly_backwards")
elseif inp.KeyCode == zalek_data.controls.fly_left then
keys_event:FireServer("stop_fly_left")
elseif inp.KeyCode == zalek_data.controls.fly_right then
keys_event:FireServer("stop_fly_right")
end
end
end
end
end
uis.InputEnded:Connect(handle_keybindsEnded)
server:
local frontbackTilt = math.rad(10)
local leftrightTilt = math.rad(15)
local clampedfrontbackTilt = math.clamp(frontbackTilt, -frontbackTilt, frontbackTilt)
local clampedleftrightTilt = math.clamp(leftrightTilt, -leftrightTilt, leftrightTilt)
local function tiltcar(p, action_name)
local align_orientation = zalek.car_body.AlignOrientation
if action_name == "fly_forward" then
align_orientation.CFrame = align_orientation.CFrame * CFrame.Angles(0,0,-clampedfrontbackTilt)
elseif action_name == "fly_backwards" then
align_orientation.CFrame = align_orientation.CFrame * CFrame.Angles(0,0,clampedfrontbackTilt)
elseif action_name == "fly_left" then
align_orientation.CFrame = align_orientation.CFrame * CFrame.Angles(-clampedleftrightTilt,0,0)
elseif action_name == "fly_right" then
align_orientation.CFrame = align_orientation.CFrame * CFrame.Angles(clampedleftrightTilt,0,0)
elseif action_name == "stop_fly_forward" then
align_orientation.CFrame = CFrame.new(0,0,0)
elseif action_name == "stop_fly_backwards" then
align_orientation.CFrame = CFrame.new(0,0,0)
elseif action_name == "stop_fly_left" then
align_orientation.CFrame = CFrame.new(0,0,0)
elseif action_name == "stop_fly_right" then
align_orientation.CFrame = CFrame.new(0,0,0)
end
end
keys_event.OnServerEvent:Connect(tiltcar)