Lately, I have made a simple vehicle with lights, and I am trying to add reverse lights to it, but I only would like them to activate when the VehicleSeat is moving backwards (relative to Back face). I believe this might use CFrame, but I currently have no idea how to do this.
Here's the script for the motors and lights I currently have. I just need to know how to detect if the seat is moving backwards on its local Z-axis, so I can combine that with the Throttle detection.
seat = script.Parent
wheels = script.Parent.Parent
frontleft = wheels.FrontLeft.Motor
frontright = wheels.FrontRight.Motor
rearleft = wheels.RearLeft.Motor
rearright = wheels.RearRight.Motor
left = wheels.LeftSteer.Steer
right = wheels.RightSteer.Steer
body = wheels.Parent.Body
while true do
wait()
if seat.Throttle > 0 then
frontleft.AngularVelocity = 60
frontright.AngularVelocity = -60
rearleft.AngularVelocity = 60
rearright.AngularVelocity = -60
body.BrakeL.Material = Enum.Material.SmoothPlastic
body.BrakeM.Material = Enum.Material.SmoothPlastic
body.BrakeR.Material = Enum.Material.SmoothPlastic
body.BrakeL.PointLight.Enabled = false
body.BrakeM.PointLight.Enabled = false
body.BrakeR.PointLight.Enabled = false
end
if seat.Throttle == 0 then
frontleft.AngularVelocity = 0
frontright.AngularVelocity = 0
rearleft.AngularVelocity = 0
rearright.AngularVelocity = 0
end
if seat.Throttle < 0 then
frontleft.AngularVelocity = -60
frontright.AngularVelocity = 60
rearleft.AngularVelocity = -60
rearright.AngularVelocity = 60
body.BrakeL.Material = Enum.Material.Neon
body.BrakeM.Material = Enum.Material.Neon
body.BrakeR.Material = Enum.Material.Neon
body.BrakeL.PointLight.Enabled = true
body.BrakeM.PointLight.Enabled = true
body.BrakeR.PointLight.Enabled = true
end
if seat.Steer > 0 then
left.TargetAngle = 30
right.TargetAngle = 30
left.AngularSpeed = 5
right.AngularSpeed = 5
end
if seat.Steer == 0 then
left.TargetAngle = 0
right.TargetAngle = 0
left.AngularSpeed = 5
right.AngularSpeed = 5
end
if seat.Steer < 0 then
left.TargetAngle = -30
right.TargetAngle = -30
left.AngularSpeed = 5
right.AngularSpeed = 5
end
end
Also just an off-topic note, IDK if this is happening on your computers too or just mine, but the advertisement for "Community Chat" is blocking out buttons, disallowing me to post questions, or write them (had to use Ctrl-MouseWheel to access "Ask Question" button)

1 comment
Disable community chat in settings.