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 RunService = game:GetService("RunService")
- local UserInputService = game:GetService("UserInputService")
- local function onRenderStep(deltaTime)
- local maxSpeed = seat.Configuration.MaxSpeed.Value
- local torque = seat.Configuration.Torque.Value * 1000
- leftDrive.AngularVelocity = maxSpeed * seat.Throttle
- rightDrive.AngularVelocity = -maxSpeed * seat.Throttle
- rightDrive.MotorMaxTorque = torque
- leftDrive.MotorMaxTorque = torque
- local steeringAngle = seat.Configuration.SteerAngle.Value
- local turnSpeed = seat.Configuration.TurnSpeed.Value
- steerHingeR.TargetAngle = steeringAngle * seat.Steer
- steerHingeL.TargetAngle = steeringAngle * seat.Steer
- steerHingeR.AngularSpeed = turnSpeed
- steerHingeL.AngularSpeed = turnSpeed
- if seat.Throttle == -1 then
- car.TailLights1.SpotLight.Enabled = true
- car.TailLights2.SpotLight.Enabled = true
- else
- car.TailLights1.SpotLight.Enabled = false
- car.TailLights2.SpotLight.Enabled = false
- end
- end
- RunService.RenderStepped:Connect(onRenderStep)
- local function BrakeInputBegan(input,gameProcessed) -- Handbrake
- 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(function(input, processed)
- if input.UserInputType == Enum.UserInputType.Gamepad1 then
- if input.KeyCode == Enum.KeyCode.ButtonB then
- 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
- end
- end)
- UserInputService.InputEnded:connect(function(input, processed)
- if input.UserInputType == Enum.UserInputType.Gamepad1 then
- if input.KeyCode == Enum.KeyCode.ButtonB then
- leftDrive.ActuatorType = "Motor"
- rightDrive.ActuatorType = "Motor"
- end
- end
- end)
- UserInputService.InputBegan:connect(BrakeInputBegan)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement