Hi everybody! I've been working on my cars for a while, and I ran into a bug that caused lag when turning wheels. I figured out the problem: it was a "while true do" statement, located in the braking script. I've removed the statement but now, when I press "S" (to brake) , the light comes on, but when I press "W" (to accelerate), it is still on, until I press "S" again. Here's the code:

local mouse=game.Players.LocalPlayer:GetMouse()
script.Parent:WaitForChild("src")
src=script.Parent.src.Value
mouse.KeyDown:connect(function(key)
	if key=="s" then 
		if src.Value ~= 2 then
			src.Value = src.Value + 1
		else
			src.Value = 1
		end		
	end
	script.Parent.src.Value = src
end)
src.Parent.ChildRemoved:connect(function(child)
	if child.Name=="SeatWeld" then 
		src.Value = -1
		script.Parent:Destroy()
	end
end)

My question is, is there a way to automatically turn off the brake lights after pressing W, A, or D, without using "while true do"?

1 comment

0

There isn't anything her that is controlling a light. What controls the light?