ha=false hd=false hs=false hw=false imgassets={hazardoff="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\052\054\048";hazardon="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\052\055\051";leftyoff="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\052\057\048",leftyon="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\052\057\057",rightyoff="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\053\049\048";rightyon="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\053\051\053",outoff="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\053\053\050",outon="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\053\054\053";offoff="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\053\056\053";offon="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\054\048\052",onoff="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\051\057\055\050\050",onon="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\051\057\055\050\052";x4off="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\054\049\051",x4on="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\054\050\051";x2off="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\054\051\056",x2on="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\054\053\055",fastoff="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\054\055\054",faston="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\054\057\050";slowoff="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\055\048\048",slowon="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\050\053\055\048\055";lightsoff="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\053\057\051\049\055\055\053",lightson="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\053\057\051\049\055\055\057";lockoff="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\051\050\048\057\054";lockon="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\051\050\049\049\052",leftturn="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\053\057\051\049\053\052\050";rightturn="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\053\057\051\049\053\050\057",fltd="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\049\054\053\051\049\053\048\049"}for u,R in pairs(imgassets)do(Game:GetService("\067\111\110\116\101\110\116\080\114\111\118\105\100\101\114")):Preload(R)end if gear==1 then script.Parent.dn.TextColor3=Color3.new(.3,.3,.3)script.Parent.dn.Style="\082\111\098\108\111\120\066\117\116\116\111\110"end if gear==maxgear then script.Parent.up.TextColor3=Color3.new(.3,.3,.3)script.Parent.up.Style="\082\111\098\108\111\120\066\117\116\116\111\110"end function gearup()if lock then return end if gear<maxgear then gear=gear+1 watdo()script.Parent.Gear.Text=gear..("\047"..maxgear)end if gear==maxgear then script.Parent.up.TextColor3=Color3.new(.3,.3,.3)script.Parent.up.Style="\082\111\098\108\111\120\066\117\116\116\111\110"script.Parent.dn.TextColor3=Color3.new(1,1,1)script.Parent.dn.Style="\082\111\098\108\111\120\066\117\116\116\111\110\068\101\102\097\117\108\116"elseif gear==1 then script.Parent.dn.TextColor3=Color3.new(.3,.3,.3)script.Parent.dn.Style="\082\111\098\108\111\120\066\117\116\116\111\110"script.Parent.up.TextColor3=Color3.new(1,1,1)script.Parent.up.Style="\082\111\098\108\111\120\066\117\116\116\111\110\068\101\102\097\117\108\116"else script.Parent.dn.TextColor3=Color3.new(1,1,1)script.Parent.dn.Style="\082\111\098\108\111\120\066\117\116\116\111\110\068\101\102\097\117\108\116"script.Parent.up.TextColor3=Color3.new(1,1,1)script.Parent.up.Style="\082\111\098\108\111\120\066\117\116\116\111\110\068\101\102\097\117\108\116"end end function geardown()if lock then return end if gear>1 then gear=gear-1 watdo()script.Parent.Gear.Text=gear..("\047"..maxgear)end if gear==1 then script.Parent.dn.TextColor3=Color3.new(.3,.3,.3)script.Parent.dn.Style="\082\111\098\108\111\120\066\117\116\116\111\110"script.Parent.up.TextColor3=Color3.new(1,1,1)script.Parent.up.Style="\082\111\098\108\111\120\066\117\116\116\111\110\068\101\102\097\117\108\116"elseif gear==maxgear then script.Parent.up.TextColor3=Color3.new(.3,.3,.3)script.Parent.up.Style="\082\111\098\108\111\120\066\117\116\116\111\110"script.Parent.dn.TextColor3=Color3.new(1,1,1)script.Parent.dn.Style="\082\111\098\108\111\120\066\117\116\116\111\110\068\101\102\097\117\108\116"else script.Parent.dn.TextColor3=Color3.new(1,1,1)script.Parent.dn.Style="\082\111\098\108\111\120\066\117\116\116\111\110\068\101\102\097\117\108\116"script.Parent.up.TextColor3=Color3.new(1,1,1)script.Parent.up.Style="\082\111\098\108\111\120\066\117\116\116\111\110\068\101\102\097\117\108\116"end end script.Parent.up.MouseButton1Click:connect(gearup)script.Parent.dn.MouseButton1Click:connect(geardown)script.Parent.flipbutton.MouseButton1Click:connect(function()if not flipping then flipping=true local u=Instance.new("\066\111\100\121\080\111\115\105\116\105\111\110",seat)u.maxForce=Vector3.new(100000,10000000,100000)u.position=seat.Position+Vector3.new(0,10,0)local R=Instance.new("\066\111\100\121\071\121\114\111",seat)wait(3)u:Destroy()R:Destroy()flipping=false end end)function turn()if turndebounce==false then turndebounce=true wait(.05)repeat templeft=turningleft tempright=turningright script.Parent.onsound:Play()if turningleft==true then script.Parent.leftturn.Visible=true for u,R in pairs(leftturn)do R.BrickColor=BrickColor.new("\068\101\101\112 \111\114\097\110\103\101")end for u,R in pairs(leftlight)do R.BrickColor=BrickColor.new("\082\101\097\108\108\121 \114\101\100")end for u,R in pairs(leftflash)do if lightson then R.Enabled=true end end for u,R in pairs(leftbrake)do R.Brightness=2 end end if turningright==true then script.Parent.rightturn.Visible=true for u,R in pairs(rightturn)do R.BrickColor=BrickColor.new("\068\101\101\112 \111\114\097\110\103\101")end for u,R in pairs(rightlight)do R.BrickColor=BrickColor.new("\082\101\097\108\108\121 \114\101\100")end for u,R in pairs(rightflash)do if lightson then R.Enabled=true end end for u,R in pairs(rightbrake)do R.Brightness=2 end end wait(.4)script.Parent.offsound:Play()script.Parent.leftturn.Visible=false script.Parent.rightturn.Visible=false if templeft==true then for u,R in pairs(leftturn)do R.BrickColor=BrickColor.new("\078\101\111\110 \111\114\097\110\103\101")end for u,R in pairs(leftflash)do R.Enabled=false end for u,R in pairs(leftlight)do R.BrickColor=BrickColor.new("\066\114\105\103\104\116 \114\101\100")end for u,R in pairs(leftbrake)do R.Brightness=1 end else if throttle>0 then for u,R in pairs(leftlight)do R.BrickColor=BrickColor.new("\066\114\105\103\104\116 \114\101\100")end for u,R in pairs(leftbrake)do R.Brightness=1 end else for u,R in pairs(leftlight)do R.BrickColor=BrickColor.new("\082\101\097\108\108\121 \114\101\100")end for u,R in pairs(leftbrake)do R.Brightness=2 end end end if tempright==true then for u,R in pairs(rightturn)do R.BrickColor=BrickColor.new("\078\101\111\110 \111\114\097\110\103\101")end for u,R in pairs(rightflash)do R.Enabled=false end for u,R in pairs(rightlight)do R.BrickColor=BrickColor.new("\066\114\105\103\104\116 \114\101\100")end for u,R in pairs(rightbrake)do R.Brightness=1 end else if throttle>0 then for u,R in pairs(rightlight)do R.BrickColor=BrickColor.new("\066\114\105\103\104\116 \114\101\100")end for u,R in pairs(rightbrake)do R.Brightness=1 end else for u,R in pairs(rightlight)do R.BrickColor=BrickColor.new("\082\101\097\108\108\121 \114\101\100")end for u,R in pairs(rightbrake)do R.Brightness=2 end end end wait(.35)until turningleft==false and turningright==false turndebounce=false end end seat.ChildRemoved:connect(function(u)if u:IsA("\087\101\108\100")then if u.Part1.Parent==Player.Character then lock=true ha=false hd=false hs=false hw=false throttle=0 steer=0 watdo()script.Parent.close.Active=true script.Parent.close.Visible=true script.Parent.xlabel.Visible=true end end end)seat.ChildAdded:connect(function(u)if u:IsA("\087\101\108\100")then if u.Part1.Parent==Player.Character then lock=false script.Parent.close.Active=false script.Parent.close.Visible=false script.Parent.xlabel.Visible=false end end end)function exiting()lock=true steer=0 throttle=0 watdo()turningleft=false turningright=false script.Parent.flasher.Value=false script.Parent.siren.Value=false lightson=false Instance.new("\073\110\116\086\097\108\117\101",seat)for u,R in pairs(leftturn)do R.BrickColor=BrickColor.new("\078\101\111\110 \111\114\097\110\103\101")end for u,R in pairs(leftlight)do R.BrickColor=BrickColor.new("\082\101\097\108\108\121 \114\101\100")end for u,R in pairs(leftflash)do R.Enabled=false end for u,R in pairs(leftbrake)do R.Brightness=2 end for u,R in pairs(rightturn)do R.BrickColor=BrickColor.new("\078\101\111\110 \111\114\097\110\103\101")end for u,R in pairs(rightlight)do R.BrickColor=BrickColor.new("\082\101\097\108\108\121 \114\101\100")end for u,R in pairs(rightflash)do R.Enabled=false end for u,R in pairs(rightbrake)do R.Brightness=2 end script.Parent.Parent:Destroy()end function updatelights()for u,R in pairs(leftbrake)do R.Enabled=lightson end for u,R in pairs(rightbrake)do R.Enabled=lightson end for u,R in pairs(brakelight)do R.Enabled=lightson end for u,R in pairs(headlight)do R.Enabled=lightson end if lightson then script.Parent.lightimage.Image=imgassets.lightson else script.Parent.lightimage.Image=imgassets.lightsoff end end script.Parent.lights.MouseButton1Click:connect(function()if lock then return end lightson=not lightson updatelights()end)function destroycar()seat.Parent:Destroy()end script.Parent.close.MouseButton1Up:connect(exiting)Player.Character.Humanoid.Died:connect(destroycar)game.Players.PlayerRemoving:connect(function(u)if u.Name==Player.Name then destroycar()end end)for u,R in pairs(seat.Parent:GetChildren())do if R.Name=="\076\101\102\116\087\104\101\101\108"then table.insert(left,R)elseif R.Name=="\082\105\103\104\116\087\104\101\101\108"then table.insert(right,R)elseif R.Name=="\082\101\097\114\108\105\103\104\116"then table.insert(rearlight,R)elseif R.Name=="\066\114\097\107\101\108\105\103\104\116"then table.insert(brakelight,R.SpotLight)elseif R.Name=="\114\105\103\104\116\116\117\114\110"then table.insert(rightturn,R)elseif R.Name=="\108\101\102\116\116\117\114\110"then table.insert(leftturn,R)elseif R.Name=="\108\101\102\116\102\108\097\115\104"then table.insert(leftflash,R.SpotLight)elseif R.Name=="\114\105\103\104\116\102\108\097\115\104"then table.insert(rightflash,R.SpotLight)elseif R.Name=="\108\101\102\116\108\105\103\104\116"then table.insert(leftlight,R)elseif R.Name=="\114\105\103\104\116\108\105\103\104\116"then table.insert(rightlight,R)elseif R.Name=="\072\101\097\100\108\105\103\104\116"then table.insert(headlight,R.SpotLight)elseif R.Name=="\108\101\102\116\098\114\097\107\101"then table.insert(leftbrake,R.SpotLight)elseif R.Name=="\114\105\103\104\116\098\114\097\107\101"then table.insert(rightbrake,R.SpotLight)elseif R.Name=="\114\101\118\108\105\103\104\116"then table.insert(revlight,R.SpotLight)end end for u,R in pairs(left)do R.BottomParamA=0 R.BottomParamB=0 end for u,R in pairs(right)do R.BottomParamA=0 R.BottomParamB=0 end function watdo()seat.Parent.LeftMotor.DesiredAngle=math.rad(throttle<0 and 40*steer or(40*steer)/gear^.5)seat.Parent.RightMotor.DesiredAngle=math.rad(throttle<0 and 40*steer or(40*steer)/gear^.5)for u,R in pairs(left)do if throttle~=-1 then R.BottomParamA=.1/gear R.BottomParamB=(.5*gear+(steer*gear)/30)*throttle else R.BottomParamA=-0.01 R.BottomParamB=-0.5-steer/20 end end for u,R in pairs(right)do if throttle~=-1 then R.BottomParamA=-(.1/gear)R.BottomParamB=-(.5*gear-(steer*gear)/30)*throttle else R.BottomParamA=.01 R.BottomParamB=.5-steer/20 end end if throttle<1 then for u,R in pairs(rearlight)do R.BrickColor=BrickColor.new("\082\101\097\108\108\121 \114\101\100")end for u,R in pairs(brakelight)do R.Brightness=2 end if turningleft==false then for u,R in pairs(leftlight)do R.BrickColor=BrickColor.new("\082\101\097\108\108\121 \114\101\100")end for u,R in pairs(leftbrake)do R.Brightness=2 end end if turningright==false then for u,R in pairs(rightlight)do R.BrickColor=BrickColor.new("\082\101\097\108\108\121 \114\101\100")end for u,R in pairs(rightbrake)do R.Brightness=2 end end else for u,R in pairs(rearlight)do R.BrickColor=BrickColor.new("\066\114\105\103\104\116 \114\101\100")end for u,R in pairs(brakelight)do R.Brightness=1 end if turningleft==false then for u,R in pairs(leftlight)do R.BrickColor=BrickColor.new("\066\114\105\103\104\116 \114\101\100")end for u,R in pairs(leftbrake)do R.Brightness=1 end end if turningright==false then for u,R in pairs(rightlight)do R.BrickColor=BrickColor.new("\066\114\105\103\104\116 \114\101\100")end for u,R in pairs(rightbrake)do R.Brightness=1 end end end if throttle<0 then for u,R in pairs(revlight)do if lightson then R.Enabled=true end end else for u,R in pairs(revlight)do R.Enabled=false end end end;(Player:GetMouse()).KeyDown:connect(function(u)if lock then return end u=string.upper(u)if not ha and u=="\065"or u==string.char(20)and not ha then ha=true steer=steer-1 end if not hd and u=="\068"or u==string.char(19)and not hd then hd=true steer=steer+1 end if not hw and u=="\087"or u==string.char(17)and not hw then hw=true throttle=throttle+1 end if not hs and u=="\083"or u==string.char(18)and not hs then hs=true throttle=throttle-1 end if u=="\090"then geardown()end if u=="\088"then gearup()end if u=="\081"then turningleft=not turningleft turn()end if u=="\069"then turningright=not turningright turn()end watdo()end);(Player:GetMouse()).KeyUp:connect(function(u)if lock then return end u=string.upper(u)if ha and u=="\065"or u==string.char(20)and ha then steer=steer+1 ha=false end if hd and u=="\068"or u==string.char(19)and hd then steer=steer-1 hd=false end if hw and u=="\087"or u==string.char(17)and hw then throttle=throttle-1 hw=false end if hs and u=="\083"or u==string.char(18)and hs then throttle=throttle+1 hs=false end if u==""then end watdo()end)

ha=false
hd=false
hs=false
hw=false
imgassets ={
	hazardoff="http://www.roblox.com/asset/?id=116525460",
	hazardon = "http://www.roblox.com/asset/?id=116525473",
	leftyoff = "http://www.roblox.com/asset/?id=116525490",
	leftyon = "http://www.roblox.com/asset/?id=116525499",
	rightyoff = "http://www.roblox.com/asset/?id=116525510",
	rightyon = "http://www.roblox.com/asset/?id=116525535",
	outoff="http://www.roblox.com/asset/?id=116525552",
	outon = "http://www.roblox.com/asset/?id=116525565",
	offoff = "http://www.roblox.com/asset/?id=116525585",
	offon = "http://www.roblox.com/asset/?id=116525604",
	onoff = "http://www.roblox.com/asset/?id=116539722",
	onon = "http://www.roblox.com/asset/?id=116539724",
	x4off = "http://www.roblox.com/asset/?id=116525613",
	x4on = "http://www.roblox.com/asset/?id=116525623",
	x2off = "http://www.roblox.com/asset/?id=116525638",
	x2on = "http://www.roblox.com/asset/?id=116525657",
	fastoff = "http://www.roblox.com/asset/?id=116525676",
	faston = "http://www.roblox.com/asset/?id=116525692",
	slowoff = "http://www.roblox.com/asset/?id=116525700",
	slowon = "http://www.roblox.com/asset/?id=116525707",
	lightsoff = "http://www.roblox.com/asset/?id=115931775",
	lightson = "http://www.roblox.com/asset/?id=115931779",
	lockoff = "http://www.roblox.com/asset/?id=116532096",
	lockon = "http://www.roblox.com/asset/?id=116532114",
	leftturn = "http://www.roblox.com/asset/?id=115931542",
	rightturn = "http://www.roblox.com/asset/?id=115931529",
	fltd = "http://www.roblox.com/asset/?id=116531501",
}
for _,i in pairs (imgassets) do
	Game:GetService("ContentProvider"):Preload(i)
end

if gear == 1 then
	script.Parent.dn.TextColor3 = Color3.new(.3,.3,.3)
	script.Parent.dn.Style = "RobloxButton"
end
if gear == maxgear then
	script.Parent.up.TextColor3 = Color3.new(.3,.3,.3)
	script.Parent.up.Style = "RobloxButton"
end

function gearup()--activated by GUI or pressing E
	if lock then return end
	if gear < maxgear then
		gear = gear+1
		watdo()
		script.Parent.Gear.Text = (gear.."/"..maxgear)
	end
	if gear == maxgear then
		script.Parent.up.TextColor3 = Color3.new(.3,.3,.3)
		script.Parent.up.Style = "RobloxButton"
		script.Parent.dn.TextColor3 = Color3.new(1,1,1)
		script.Parent.dn.Style = "RobloxButtonDefault"
	elseif gear == 1 then
		script.Parent.dn.TextColor3 = Color3.new(.3,.3,.3)
		script.Parent.dn.Style = "RobloxButton"
		script.Parent.up.TextColor3 = Color3.new(1,1,1)
		script.Parent.up.Style = "RobloxButtonDefault"
	else
		script.Parent.dn.TextColor3 = Color3.new(1,1,1)
		script.Parent.dn.Style = "RobloxButtonDefault"
		script.Parent.up.TextColor3 = Color3.new(1,1,1)
		script.Parent.up.Style = "RobloxButtonDefault"
	end
end
function geardown()--activated by GUI or pressing Q
	if lock then return end
	if gear > 1 then
		gear = gear-1
		watdo()
		script.Parent.Gear.Text = (gear.."/"..maxgear)
	end
	if gear == 1 then
		script.Parent.dn.TextColor3 = Color3.new(.3,.3,.3)
		script.Parent.dn.Style = "RobloxButton"
		script.Parent.up.TextColor3 = Color3.new(1,1,1)
		script.Parent.up.Style = "RobloxButtonDefault"
	elseif gear == maxgear then
		script.Parent.up.TextColor3 = Color3.new(.3,.3,.3)
		script.Parent.up.Style = "RobloxButton"
		script.Parent.dn.TextColor3 = Color3.new(1,1,1)
		script.Parent.dn.Style = "RobloxButtonDefault"
	else
		script.Parent.dn.TextColor3 = Color3.new(1,1,1)
		script.Parent.dn.Style = "RobloxButtonDefault"
		script.Parent.up.TextColor3 = Color3.new(1,1,1)
		script.Parent.up.Style = "RobloxButtonDefault"
	end
end

script.Parent.up.MouseButton1Click:connect(gearup)
script.Parent.dn.MouseButton1Click:connect(geardown)

script.Parent.flipbutton.MouseButton1Click:connect(function()
	if not flipping then
		flipping = true
		local a = Instance.new("BodyPosition",seat)
		a.maxForce = Vector3.new(100000,10000000,100000)
		a.position = seat.Position + Vector3.new(0,10,0)
		local b = Instance.new("BodyGyro",seat)
		wait(3)
		a:Destroy()
		b:Destroy()
		flipping = false
	end
end)

function turn()
	if turndebounce == false then
		turndebounce = true
		wait(0.05)
		repeat
			templeft = turningleft
			tempright = turningright
			script.Parent.onsound:Play()
			if turningleft == true then
				script.Parent.leftturn.Visible = true
				for _,i in pairs (leftturn) do
					i.BrickColor = BrickColor.new("Deep orange")
				end
				for _,a in pairs (leftlight) do
					a.BrickColor = BrickColor.new("Really red")
				end
				for _,b in pairs (leftflash) do
					if lightson then
						b.Enabled = true
					end
				end
				for _,b in pairs (leftbrake) do
					b.Brightness = 2
				end
			end
			if turningright == true then
				script.Parent.rightturn.Visible = true
				for _,i in pairs (rightturn) do
					i.BrickColor = BrickColor.new("Deep orange")
				end
				for _,a in pairs (rightlight) do
					a.BrickColor = BrickColor.new("Really red")
				end
				for _,b in pairs (rightflash) do
					if lightson then
						b.Enabled = true
					end
				end
				for _,b in pairs (rightbrake) do
					b.Brightness = 2
				end
			end
			wait(0.4)
			script.Parent.offsound:Play()
			script.Parent.leftturn.Visible = false
			script.Parent.rightturn.Visible = false
			if templeft == true then
				for _,i in pairs (leftturn) do
					i.BrickColor = BrickColor.new("Neon orange")
				end
				for _,b in pairs (leftflash) do
					b.Enabled = false
				end
				for _,a in pairs (leftlight) do
					a.BrickColor = BrickColor.new("Bright red")
				end
				for _,b in pairs (leftbrake) do
					b.Brightness = 1
				end
			else
				if throttle > 0 then
					for _,a in pairs (leftlight) do
						a.BrickColor = BrickColor.new("Bright red")
					end
					for _,b in pairs (leftbrake) do
						b.Brightness = 1
					end
				else
					for _,a in pairs (leftlight) do
						a.BrickColor = BrickColor.new("Really red")
					end
					for _,b in pairs (leftbrake) do
						b.Brightness = 2
					end
				end
			end
			if tempright == true then
				for _,i in pairs (rightturn) do
					i.BrickColor = BrickColor.new("Neon orange")
				end
				for _,b in pairs (rightflash) do
					b.Enabled = false
				end
				for _,a in pairs (rightlight) do
					a.BrickColor = BrickColor.new("Bright red")
				end
				for _,b in pairs (rightbrake) do
					b.Brightness = 1
				end
			else
				if throttle > 0 then
					for _,a in pairs (rightlight) do
						a.BrickColor = BrickColor.new("Bright red")
					end
					for _,b in pairs (rightbrake) do
						b.Brightness = 1
					end
				else
					for _,a in pairs (rightlight) do
						a.BrickColor = BrickColor.new("Really red")
					end
					for _,b in pairs (rightbrake) do
						b.Brightness = 2
					end
				end
			end
			wait(0.35)
		until turningleft == false and turningright == false
		turndebounce = false
	end
end

seat.ChildRemoved:connect(function(it)
	if it:IsA("Weld") then
		if it.Part1.Parent == Player.Character then
			lock = true
			ha=false
			hd=false
			hs=false
			hw=false
			throttle = 0
			steer = 0
			watdo()
			script.Parent.close.Active = true
			script.Parent.close.Visible = true
			script.Parent.xlabel.Visible = true
		end
	end
end)
seat.ChildAdded:connect(function(it)
	if it:IsA("Weld") then
		if it.Part1.Parent == Player.Character then
			lock = false
			script.Parent.close.Active = false
			script.Parent.close.Visible = false
			script.Parent.xlabel.Visible = false
		end
	end
end)
function exiting()
	lock = true--when we close the gui stop everything
	steer = 0
	throttle = 0
	watdo()
	turningleft = false
	turningright = false
	script.Parent.flasher.Value = false
	script.Parent.siren.Value = false
	lightson = false
	Instance.new("IntValue",seat)
	for _,i in pairs (leftturn) do
		i.BrickColor = BrickColor.new("Neon orange")
	end
	for _,a in pairs (leftlight) do
		a.BrickColor = BrickColor.new("Really red")
	end
	for _,b in pairs (leftflash) do
		b.Enabled = false
	end
	for _,b in pairs (leftbrake) do
		b.Brightness = 2
	end
	for _,i in pairs (rightturn) do
		i.BrickColor = BrickColor.new("Neon orange")
	end
	for _,a in pairs (rightlight) do
		a.BrickColor = BrickColor.new("Really red")
	end
	for _,b in pairs (rightflash) do
		b.Enabled = false
	end
	for _,b in pairs (rightbrake) do
		b.Brightness = 2
	end
	script.Parent.Parent:Destroy()--destroy the 'Car' ScreenGui
end

function updatelights()
	for _,i in pairs (leftbrake) do
		i.Enabled = lightson
	end
	for _,i in pairs (rightbrake) do
		i.Enabled = lightson
	end
	for _,i in pairs (brakelight) do
		i.Enabled = lightson
	end
	for _,i in pairs (headlight) do
		i.Enabled = lightson
	end
	if lightson then
		script.Parent.lightimage.Image = imgassets.lightson
	else
		script.Parent.lightimage.Image = imgassets.lightsoff
	end
end

script.Parent.lights.MouseButton1Click:connect(function()
	if lock then return end
	lightson = not lightson
	updatelights()
end)

function destroycar()
	seat.Parent:Destroy()--destroy the car
end

script.Parent.close.MouseButton1Up:connect(exiting)
Player.Character.Humanoid.Died:connect(destroycar)

game.Players.PlayerRemoving:connect(function(Playeras)
	if Playeras.Name == Player.Name then
		destroycar()
	end
end)

for _, i in pairs (seat.Parent:GetChildren()) do--populate the tables for ease of modularity. You could have 100 left wheels if you wanted.
	if i.Name == "LeftWheel" then
		table.insert(left,i)
	elseif i.Name == "RightWheel" then
		table.insert(right,i)
	elseif i.Name == "Rearlight" then
		table.insert(rearlight,i)
	elseif i.Name == "Brakelight" then
		table.insert(brakelight,i.SpotLight)
	elseif i.Name == "rightturn" then
		table.insert(rightturn,i)
	elseif i.Name == "leftturn" then
		table.insert(leftturn,i)
	elseif i.Name == "leftflash" then
		table.insert(leftflash,i.SpotLight)
	elseif i.Name == "rightflash" then
		table.insert(rightflash,i.SpotLight)
	elseif i.Name == "leftlight" then
		table.insert(leftlight,i)
	elseif i.Name == "rightlight" then
		table.insert(rightlight,i)
	elseif i.Name == "Headlight" then
		table.insert(headlight,i.SpotLight)
	elseif i.Name == "leftbrake" then
		table.insert(leftbrake,i.SpotLight)
	elseif i.Name == "rightbrake" then
		table.insert(rightbrake,i.SpotLight)
	elseif i.Name == "revlight" then
		table.insert(revlight,i.SpotLight)
	end
end

for _,l in pairs (left) do
	l.BottomParamA = 0
	l.BottomParamB = 0
end
for _,r in pairs (right) do
	r.BottomParamA = 0
	r.BottomParamB = 0
end

function watdo()
	seat.Parent.LeftMotor.DesiredAngle = math.rad(throttle < 0 and 40* steer or 40*steer/gear^0.5)
	seat.Parent.RightMotor.DesiredAngle = math.rad(throttle < 0 and 40* steer or 40*steer/gear^0.5)
	for _,l in pairs (left) do--I do it this way so that it's not searching the model every time an input happens
		if throttle ~= -1 then
			l.BottomParamA = (.1/gear)
			l.BottomParamB = (.5*gear+steer*gear/30)*throttle
		else
			l.BottomParamA = -.01
			l.BottomParamB = -.5-steer/20
		end
	end
	for _,r in pairs (right) do
		if throttle ~= -1 then
			r.BottomParamA = -(.1/gear)
			r.BottomParamB = -(.5*gear-steer*gear/30)*throttle
		else
			r.BottomParamA = .01
			r.BottomParamB = .5-steer/20
		end
	end
	if throttle < 1 then
		for _,g in pairs (rearlight) do
			g.BrickColor = BrickColor.new("Really red")
		end
		for _,b in pairs (brakelight) do
			b.Brightness = 2
		end
		if turningleft == false then
			for _,a in pairs (leftlight) do
				a.BrickColor = BrickColor.new("Really red")
			end
			for _,b in pairs (leftbrake) do
				b.Brightness = 2
			end
		end
		if turningright == false then
			for _,a in pairs (rightlight) do
				a.BrickColor = BrickColor.new("Really red")
			end
			for _,b in pairs (rightbrake) do
				b.Brightness = 2
			end
		end
	else
		for _,g in pairs (rearlight) do
			g.BrickColor = BrickColor.new("Bright red")
		end
		for _,b in pairs (brakelight) do
			b.Brightness = 1
		end
		if turningleft == false then
			for _,a in pairs (leftlight) do
				a.BrickColor = BrickColor.new("Bright red")
			end
			for _,b in pairs (leftbrake) do
				b.Brightness = 1
			end
		end
		if turningright == false then
			for _,a in pairs (rightlight) do
				a.BrickColor = BrickColor.new("Bright red")
			end
			for _,b in pairs (rightbrake) do
				b.Brightness = 1
			end
		end
	end
	if throttle < 0 then
		for _,b in pairs (revlight) do
			if lightson then
				b.Enabled = true
			end
		end
	else
		for _,b in pairs (revlight) do
			b.Enabled = false
		end
	end	
end

Player:GetMouse().KeyDown:connect(function(key)--warning ugly button code
	if lock then return end
	key = string.upper(key)
	if not ha and key == "A" or key == string.char(20) and not ha then
		ha = true
		steer = steer-1
	end
	if not hd and key == "D" or key == string.char(19) and not hd then
		hd = true
		steer = steer+1
	end
	if not hw and key == "W" or key == string.char(17) and not hw then
		hw = true
		throttle = throttle+1
	end
	if not hs and key == "S" or key == string.char(18) and not hs then
		hs = true
		throttle = throttle-1
	end
	if key == "Z" then
		geardown()
	end
	if key == "X" then
		gearup()
	end
	if key == "Q" then
		turningleft = not turningleft
		turn()
	end
	if key == "E" then
		turningright = not turningright
		turn()
	end
	watdo()
end)
Player:GetMouse().KeyUp:connect(function(key)
	if lock then return end
	key = string.upper(key)
	if ha and key == "A" or key == string.char(20)and ha then
		steer = steer+1
		ha = false
	end
	if hd and key == "D" or key == string.char(19) and hd then
		steer = steer-1
		hd = false
	end
	if hw and key == "W" or key == string.char(17) and hw then
		throttle = throttle-1
		hw = false
	end
	if hs and key == "S" or key == string.char(18) and hs then
		throttle = throttle+1
		hs = false
	end
	if key == "" then
		--more keys if I need them
	end
	watdo()
end)	
