local F=false local w=.5 local v=.1 local B=7 local b=3 function seatChildAddedHandler(w)if w.Name=="\083\101\097\116\087\101\108\100"then print("\084\117\114\110 \099\097\114 \079\078")F=true if hasSmoke then smoke.Enabled=true end smoke.Opacity=v colorAll(headlights,lightColor_on)fire.Size=B if hasFire then fire.Enabled=true end wait(.3)fire.Size=b if seat.Throttle==0 then fire.Enabled=false end end end function seatChildRemovedHandler(w)if w.Name=="\083\101\097\116\087\101\108\100"then print("\084\117\114\110 \099\097\114 \079\070\070")F=false smoke.Enabled=false colorAll(headlights,lightColor_off)end end function showBigFire()fire.Size=B if hasFire then fire.Enabled=true end wait(.3)if seat.Throttle==1 then fire.Size=b end wait(1)if seat.Throttle==1 then fire.Enabled=false end end function forwardFunction() end function backwardFunction() end function colorAll(F,w)for v=1,#F,1 do F[v].BrickColor=w end end function seatChangedHandler(F)if F=="\084\104\114\111\116\116\108\101"then if seat.Throttle==1 then colorAll(brakelights,brakeColor_off)smoke.Opacity=w local F=coroutine.create(showBigFire)coroutine.resume(F)local v=coroutine.create(forwardFunction)coroutine.resume(v)elseif seat.Throttle==0 then colorAll(brakelights,brakeColor_on)smoke.Opacity=v fire.Enabled=false wait(.9)colorAll(brakelights,brakeColor_off)elseif seat.Throttle==-1 then colorAll(brakelights,lightColor_on)smoke.Opacity=v fire.Enabled=false local F=coroutine.create(backwardFunction)coroutine.resume(F)end end end


local driverInSeat = false
local smokeOpacity_throttleOn = 0.5
local smokeOpacity_throttleOff = 0.1
local fireSize_big = 7
local fireSize_small = 3

function seatChildAddedHandler(child)
	if child.Name=="SeatWeld" then
		print("Turn car ON")
		driverInSeat = true
		if(hasSmoke) then 
			smoke.Enabled = true 
		end
		smoke.Opacity = smokeOpacity_throttleOff
		colorAll(headlights, lightColor_on)
		fire.Size = fireSize_big
		if(hasFire) then 
			fire.Enabled = true
		end
		wait(0.3)
		fire.Size = fireSize_small
		if seat.Throttle==0 then
			fire.Enabled = false
		end
	end
end

function seatChildRemovedHandler(child)
	if child.Name=="SeatWeld" then
		print("Turn car OFF")
		driverInSeat = false
		smoke.Enabled = false
		colorAll(headlights, lightColor_off)
	end
end

function showBigFire()
	fire.Size = fireSize_big
	if(hasFire) then
		fire.Enabled = true
	end
	wait(0.3)
	if seat.Throttle==1 then
		fire.Size = fireSize_small
	end
	wait(1)
	if seat.Throttle==1 then
		fire.Enabled = false
	end
end

function forwardFunction()
	--print("forwardFunction()")
end

function backwardFunction()
	--print("backwardFunction()")
end

function colorAll(parts, color)
	for i=1, #parts do
		parts[i].BrickColor = color
	end
end

function seatChangedHandler(prop)
	if prop=="Throttle" then
		if seat.Throttle==1 then
			-- Throttle Forward
			colorAll(brakelights, brakeColor_off)
			smoke.Opacity = smokeOpacity_throttleOn
			local co = coroutine.create(showBigFire)
			coroutine.resume(co)
			local co2 = coroutine.create(forwardFunction)
			coroutine.resume(co2)
		elseif seat.Throttle==0 then
			-- Throttle Off
			colorAll(brakelights, brakeColor_on)
			smoke.Opacity = smokeOpacity_throttleOff
			fire.Enabled = false
			wait(0.9)
			colorAll(brakelights, brakeColor_off)
		elseif seat.Throttle==-1 then
			-- Throttle Reverse
			colorAll(brakelights, lightColor_on)
			smoke.Opacity = smokeOpacity_throttleOff
			fire.Enabled = false
			local co = coroutine.create(backwardFunction)
			coroutine.resume(co)
		end
	end
end
