Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)()

3 comments

0

Also missing an while loop

0

How would I go about that?

0

I fixed it.

This discussion is preserved as it was. New answers, comments, and votes are closed.