-------------------------


mouse.KeyDown:connect(function (key)
    key = string.lower(key)
        if key == "a" or key:byte() == 20 then
                a = true
                h.DesiredAngle = 0.3
        elseif key == "d" or key:byte() == 19 then
                d = true
                h.DesiredAngle = -0.3
        elseif key == "w" or key:byte() == 17 then
                w = true
                rwd.Throttle = 1
				rwd.Torque = tq
                carSeat.Throttle = 1				
				carSeat.Torque = cst
				carSeat.Parent.Parent.HW.B1.CanCollide = false
				carSeat.Parent.Parent.HW.B2.CanCollide = false
         elseif key == "s" or key:byte() == 18 then
                s = true
                carSeat.Throttle = -1      
                carSeat.Torque = fbrk
                rwd.Throttle = -1      
                rwd.Torque = brk
			elseif key:byte() == 48 then				
				hb1.CanCollide = true
				hb2.CanCollide = true
                end
end)
 
mouse.KeyUp:connect(function (key)
    key = string.lower(key)
        if key == "a" or key:byte() == 20 then
                print("a up")
                if d == false then
                	h.DesiredAngle = 0
                end
        elseif key == "d" or key:byte() == 19 then
                print("d up")
                if a == false then
                	h.DesiredAngle = 0
				end
		end
        a = false
        d = false
end)
 
mouse.KeyUp:connect(function (key)
    key = string.lower(key)
if key == "w" or key == "s" or key:byte() == 17 or key:byte() == 18 then
        rwd.Throttle = 0
rwd.Torque = cst
        carSeat.Throttle = 0
carSeat.Torque = cst
		carSeat.Parent.Parent.HW.B1.CanCollide = false
		carSeat.Parent.Parent.HW.B2.CanCollide = false
			elseif key:byte() == 48 then
		hb1.CanCollide = false
		hb2.CanCollide = false
        end
end)   

standButton.MouseButton1Click:connect(function()
	local ks = carSeat.Parent.KP.Motor
	ks.MaxVelocity = .1
        if ks.DesiredAngle == 0 then
			ks.DesiredAngle = -1.571
        else   
			ks.DesiredAngle = 0
        end
end)

camButton.MouseButton1Click:connect(function()
		if cam == ("car") then
			Camera.CameraSubject = player.Character.Humanoid
			Camera.CameraType = ("Attach")
			cam = ("lockplr")
		elseif cam == ("lockplr") then
			Camera.CameraSubject = player.Character.Humanoid
			Camera.CameraType = ("Custom")
			cam = ("freeplr")
        elseif cam == ("freeplr") then
			Camera.CameraSubject = carSeat
			Camera.CameraType = ("Custom")
			cam = ("car")
        end
end)
