--Manage input mode

UIS.InputBegan:Connect(function(InputObj)
	local CurrentInputType = Input.InputMode
	if InputObj.KeyCode == Enum.KeyCode.ButtonA or InputObj.KeyCode == Enum.KeyCode.ButtonX or InputObj.KeyCode == Enum.KeyCode.ButtonB then
		Input.InputMode = "Gamepad"
	elseif InputObj.UserInputType == Enum.UserInputType.Keyboard then
		Input.InputMode = "Keyboard" 
	elseif InputObj.UserInputType == Enum.UserInputType.Touch then
		Input.InputMode = "Touch"
		if CurrentInputType~=Input.InputMode then
			RunTouchControls()
		end
	end
	if CurrentInputType~=Input.InputMode then
		script.TypeChanged:Fire(Input.InputMode)
	end
end)

function KeyChanged()
	--Handle ForwardBack
	local ForwardKey = ( KeyStates[KeyMap.Forward.PrimaryKey] or KeyStates[KeyMap.Forward.SecondaryKey] )
	local BackwardKey = ( KeyStates[KeyMap.Backward.PrimaryKey] or KeyStates[KeyMap.Backward.SecondaryKey] )
	if ForwardKey and BackwardKey then
		Input.Forward = 0
	elseif ForwardKey then
		Input.Forward = 1
	elseif BackwardKey then
		Input.Forward = -1
	else
		Input.Forward = 0
	end
	
	--Handle Strafe
	local StrafeLKey = ( KeyStates[KeyMap.StrafeL.PrimaryKey] or KeyStates[KeyMap.StrafeL.SecondaryKey] )
	local StrafeRKey = ( KeyStates[KeyMap.StrafeR.PrimaryKey] or KeyStates[KeyMap.StrafeR.SecondaryKey] )
	if StrafeLKey and StrafeRKey then
		Input.Strafe = 0
	elseif StrafeLKey then
		Input.Strafe = 1
	elseif StrafeRKey then
		Input.Strafe = -1
	else
		Input.Strafe = 0
	end
	
	--Handle Shift
	local ShiftUpKey = ( KeyStates[KeyMap.ShiftUp.PrimaryKey] or KeyStates[KeyMap.ShiftUp.SecondaryKey] )
	local ShiftDownKey = ( KeyStates[KeyMap.ShiftDown.PrimaryKey] or KeyStates[KeyMap.ShiftDown.SecondaryKey] )
	if ShiftUpKey and ShiftDownKey then
		Input.Shift = 0
	elseif ShiftUpKey then
		Input.Shift = 1
	elseif ShiftDownKey then
		Input.Shift = -1
	else
		Input.Shift = 0
	end
	