I'm trying to make a light system, so when a red light shows, the max speed of the car is turned to 0 so nobody will be able to move, when the light is turned to amber (gold) the car will only be able to get to 40 and when it is green, the car will be able to go to 60. I have tried a few different ways, this script is in the kart. I have also tried a function type when when the red light button is pressed it changes the cars speed but nothing seems to be working. Any help is appreciated :)
if workspace.Lights.Light1.BrickColor == ("Really red") then workspace.Karts.Kart1.Seat.VehicleSeat.MaxSpeed = 0 else if workspace.Lights.Light1.BrickColor == ("Gold") then workspace.Karts.Kart1.Seat.VehicleSeat.MaxSpeed = 40 else workspace.Karts.Kart1.Seat.VehicleSeat.MaxSpeed = 60 end end
Hello naplank. The problem is that you forgot the BrickColor.new
in front of the BrickColor string. Try using this:
coroutine.wrap(function() while wait() do if workspace.Lights.Light1.BrickColor == BrickColor.new("Really red") then workspace.Karts.Kart1.Seat.VehicleSeat.MaxSpeed = 0 else if workspace.Lights.Light1.BrickColor == BrickColor.new("Gold") then workspace.Karts.Kart1.Seat.VehicleSeat.MaxSpeed = 40 else workspace.Karts.Kart1.Seat.VehicleSeat.MaxSpeed = 60 end end end end)()