local E=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local F=0 local S=0 local Y=0 local X=0 local r=0 stdz=script.Value local B={[Enum.KeyCode.ButtonL1]={f=function()if control.Value=="\067\111\110\116\114\111\108\108\101\114"then if script.Parent.Storage.CurrentGear.Value~=1 then script.Parent.Functions.ShiftDownRequested.Value=true end print("\068\079\087\078")end end,deb=false};[Enum.KeyCode.ButtonR1]={f=function()if control.Value=="\067\111\110\116\114\111\108\108\101\114"then if script.Parent.Storage.CurrentGear.Value~=script.Parent.Storage.AmountOfGears.Value+2 then script.Parent.Functions.ShiftUpRequested.Value=true end print("\085\080")end end;deb=false}}function DealWithInput(E,F)if E.UserInputType==Enum.UserInputType.Keyboard then local F=carSeat.Velocity.magnitude if E.KeyCode==Enum.KeyCode.A then if E.UserInputState==Enum.UserInputState.Begin then elseif E.UserInputState==Enum.UserInputState.End then end end if E.KeyCode==Enum.KeyCode.D then if E.UserInputState==Enum.UserInputState.Begin then elseif E.UserInputState==Enum.UserInputState.End then end end if E.KeyCode==Enum.KeyCode.W then if E.UserInputState==Enum.UserInputState.Begin then elseif E.UserInputState==Enum.UserInputState.End then end end if E.KeyCode==Enum.KeyCode.S then if E.UserInputState==Enum.UserInputState.Begin then elseif E.UserInputState==Enum.UserInputState.End then end end end if E.KeyCode==Enum.KeyCode.ButtonX then if E.UserInputState==Enum.UserInputState.Begin then print("\104\101\108\112 \109\101 \115\111\110\110\121")elseif E.UserInputState==Enum.UserInputState.End then end end if control.Value=="\075\101\121\098\111\097\114\100"then local E=math.max(1,(mouse.ViewSizeX*67)/200)local F=.04 local S=(mouse.X-mouse.ViewSizeX/2)/E if math.abs(S)<=F then Gval=0 else Gval=(math.max(math.min(math.abs(S)-F,1-F),0)/(1-F))^1*(S/math.abs(S))end end if control.Value=="\067\111\110\116\114\111\108\108\101\114"then if E.UserInputType.Name:find("\071\097\109\101\112\097\100")then if E.KeyCode==Enum.KeyCode.Thumbstick1 then if E.Position.X>stdz.Value then if script.Parent.Storage.Control.Value=="\067\111\110\116\114\111\108\108\101\114"then script.Parent.Storage.Steer.Value=(E.Position.X-stdz.Value)*(1/(1-stdz.Value))end elseif E.Position.X<-stdz.Value then if script.Parent.Storage.Control.Value=="\067\111\110\116\114\111\108\108\101\114"then script.Parent.Storage.Steer.Value=(E.Position.X+stdz.Value)*(1/(1-stdz.Value))end else script.Parent.Storage.Steer.Value=0 end elseif E.KeyCode==Enum.KeyCode.ButtonR2 then X=E.Position.Z script.Parent.Storage.Throttle.Throttle.Value=X elseif E.KeyCode==Enum.KeyCode.ButtonL2 then r=E.Position.Z script.Parent.Storage.Brake.Value=r elseif B[E.KeyCode]then local F=B[E.KeyCode]if E.Position.Z>.5 and not F.deb then F.deb=true F.f()elseif E.Position.Z<.5 then F.deb=false end end end end end E.InputBegan:connect(DealWithInput)E.InputChanged:connect(DealWithInput)E.InputEnded:connect(DealWithInput)

local UserInputService = game:GetService("UserInputService")
 
local steer = 0
local throttle = 0
local brake = 0
 
local RTriggerValue = 0
local LTriggerValue = 0

stdz = script.Value

				
local PositiveEdgeButton = {
[Enum.KeyCode.ButtonL1]={f=function()
	if control.Value == "Controller" then
		if script.Parent.Storage.CurrentGear.Value ~= 1 then
	script.Parent.Functions.ShiftDownRequested.Value = true	
	end
	print("DOWN") --ADD LOWER LIMIT [AND UPPER 4 OTHER 1]
		end
	
end;deb=false};


[Enum.KeyCode.ButtonR1]={f=function() 
	if control.Value == "Controller" then
		if script.Parent.Storage.CurrentGear.Value ~= script.Parent.Storage.AmountOfGears.Value +2 then
		script.Parent.Functions.ShiftUpRequested.Value = true	
		end
		print("UP")
	end
end;deb=false}
}
 
function DealWithInput(input,IsRobloxFunction)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		local speed = carSeat.Velocity.magnitude
		if input.KeyCode == Enum.KeyCode.A then
			if input.UserInputState == Enum.UserInputState.Begin then 
			elseif input.UserInputState == Enum.UserInputState.End then 
			end
		end
		if input.KeyCode == Enum.KeyCode.D then
			if input.UserInputState == Enum.UserInputState.Begin then 
			elseif input.UserInputState == Enum.UserInputState.End then 
			end
		end
		if input.KeyCode == Enum.KeyCode.W then
			if input.UserInputState == Enum.UserInputState.Begin then 
			elseif input.UserInputState == Enum.UserInputState.End then 
			end
		end
		if input.KeyCode == Enum.KeyCode.S then
			if input.UserInputState == Enum.UserInputState.Begin then
			elseif input.UserInputState == Enum.UserInputState.End then
			end
		end
	end
	
	if input.KeyCode == Enum.KeyCode.ButtonX then 
				if input.UserInputState == Enum.UserInputState.Begin then print("help me sonny")
				
				elseif input.UserInputState == Enum.UserInputState.End then
				
				end
	end
	
	if control.Value == "Keyboard" then
			local LRpix = math.max(1,mouse.ViewSizeX*67/200)
			local dZoe = 0.04
			local MousePx = ((mouse.X-mouse.ViewSizeX/2)/LRpix) --print(MousePx)
			if math.abs(MousePx)<=dZoe then
				Gval = 0
			else
				Gval = (math.max(math.min((math.abs(MousePx)-dZoe),(1-dZoe)),0)/(1-dZoe))^1 * (MousePx / math.abs(MousePx))
			end
			
			--add if here
			---mouse.Button1Down:connect(function()
			---print("LeftClick")
			---end)
			
			---mouse.Button2Down:connect(function()
			---print("RightClick")
			--end)
	end
	
	if control.Value == "Controller" then
		if input.UserInputType.Name:find("Gamepad") then
			--------
			if input.KeyCode == Enum.KeyCode.Thumbstick1 then
				if input.Position.X > stdz.Value then
					if script.Parent.Storage.Control.Value == "Controller" then
					script.Parent.Storage.Steer.Value = (((input.Position.X)-stdz.Value)*(1/(1-stdz.Value))) end
				elseif input.Position.X < -stdz.Value then
					if script.Parent.Storage.Control.Value == "Controller" then
					script.Parent.Storage.Steer.Value = (((input.Position.X)+stdz.Value)*(1/(1-stdz.Value))) end
				else
					script.Parent.Storage.Steer.Value = 0
				end
			elseif input.KeyCode == Enum.KeyCode.ButtonR2 then
				RTriggerValue = input.Position.Z
				script.Parent.Storage.Throttle.Throttle.Value = RTriggerValue
			elseif input.KeyCode == Enum.KeyCode.ButtonL2 then
				LTriggerValue = input.Position.Z
				script.Parent.Storage.Brake.Value = LTriggerValue
			elseif PositiveEdgeButton[input.KeyCode] then
				local fn = PositiveEdgeButton[input.KeyCode]
				if input.Position.Z > 0.5 and not fn.deb then
					fn.deb = true
					fn.f()
				elseif input.Position.Z < 0.5 then
					fn.deb = false
				end
			end
		end
	end
end
UserInputService.InputBegan:connect(DealWithInput)
UserInputService.InputChanged:connect(DealWithInput)
UserInputService.InputEnded:connect(DealWithInput)
