Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer.Name
- local car = game.Workspace[player.."Car"]
- local seat = car.VehicleSeat
- local leftDrive = car.RearAxle.LeftDrive
- local rightDrive = car.RearAxle.RightDrive
- local steerHingeR = car.AxleR.SteerHingeR
- local steerHingeL = car.AxleL.SteerHingeL
- local UserInputService = game:GetService("UserInputService")
- local w = 0
- local function WInputBegan(input,gameProcessed) -- W
- if input.UserInputType == Enum.UserInputType.Keyboard then
- while UserInputService:IsKeyDown(Enum.KeyCode.W) == true do
- wait()
- local maxSpeed = seat.Configuration.MaxSpeed.Value
- local torque = seat.Configuration.Torque.Value * 1000
- leftDrive.AngularVelocity = maxSpeed * 1
- rightDrive.AngularVelocity = -maxSpeed * 1
- rightDrive.MotorMaxTorque = torque
- leftDrive.MotorMaxTorque = torque
- end
- leftDrive.AngularVelocity = 0
- rightDrive.AngularVelocity = 0
- end
- end
- local function SInputBegan(input,gameProcessed) -- S
- if input.UserInputType == Enum.UserInputType.Keyboard then
- while UserInputService:IsKeyDown(Enum.KeyCode.S) == true do
- wait()
- local maxSpeed = seat.Configuration.MaxSpeed.Value
- local torque = seat.Configuration.Torque.Value * 1000
- leftDrive.AngularVelocity = maxSpeed * -1
- rightDrive.AngularVelocity = -maxSpeed * -1
- rightDrive.MotorMaxTorque = torque
- leftDrive.MotorMaxTorque = torque
- car.TailLights1.SpotLight.Enabled = true
- car.TailLights2.SpotLight.Enabled = true
- end
- leftDrive.AngularVelocity = 0
- rightDrive.AngularVelocity = 0
- car.TailLights1.SpotLight.Enabled = false
- car.TailLights2.SpotLight.Enabled = false
- end
- end
- local function AInputBegan(input,gameProcessed) -- A
- if input.UserInputType == Enum.UserInputType.Keyboard then
- while UserInputService:IsKeyDown(Enum.KeyCode.A) == true do
- wait()
- local steeringAngle = seat.Configuration.SteerAngle.Value
- local turnSpeed = seat.Configuration.TurnSpeed.Value
- steerHingeR.TargetAngle = steeringAngle * -1
- steerHingeL.TargetAngle = steeringAngle * -1
- steerHingeR.AngularSpeed = turnSpeed
- steerHingeL.AngularSpeed = turnSpeed
- end
- steerHingeR.TargetAngle = 0
- steerHingeL.TargetAngle = 0
- end
- end
- local function DInputBegan(input,gameProcessed) -- D
- if input.UserInputType == Enum.UserInputType.Keyboard then
- while UserInputService:IsKeyDown(Enum.KeyCode.D) == true do
- wait()
- local steeringAngle = seat.Configuration.SteerAngle.Value
- local turnSpeed = seat.Configuration.TurnSpeed.Value
- steerHingeR.TargetAngle = steeringAngle * 1
- steerHingeL.TargetAngle = steeringAngle * 1
- steerHingeR.AngularSpeed = turnSpeed
- steerHingeL.AngularSpeed = turnSpeed
- end
- steerHingeR.TargetAngle = 0
- steerHingeL.TargetAngle = 0
- end
- end
- local function BInputBegan(input,gameProcessed) -- B
- if input.UserInputType == Enum.UserInputType.Keyboard then
- while UserInputService:IsKeyDown(Enum.KeyCode.B) == true do
- wait()
- local lockangle = leftDrive.CurrentAngle
- local lockangle2 = rightDrive.CurrentAngle
- leftDrive.ActuatorType = "Servo"
- rightDrive.ActuatorType = "Servo"
- leftDrive.TargetAngle = lockangle
- leftDrive.ServoMaxTorque = 100000
- rightDrive.TargetAngle = lockangle2
- rightDrive.ServoMaxTorque = 100000
- end
- leftDrive.ActuatorType = "Motor"
- rightDrive.ActuatorType = "Motor"
- end
- end
- UserInputService.InputBegan:connect(WInputBegan)
- UserInputService.InputBegan:connect(SInputBegan)
- UserInputService.InputBegan:connect(AInputBegan)
- UserInputService.InputBegan:connect(DInputBegan)
- UserInputService.InputBegan:connect(BInputBegan)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement