Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Light system that also controls the max speed of a vehicle?

Asked by 4 years ago

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

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)()
0
Also missing an while loop Leamir 3138 — 4y
0
How would I go about that? naplank 9 — 4y
0
I fixed it. youtubemasterWOW 2741 — 4y
Ad

Answer this question