for I,n in pairs(script.Parent.Parent:GetChildren())do if string.find(n.Name,"\070\082")then FRtire=n.PhysicsTire elseif string.find(n.Name,"\070\076")then FLtire=n.PhysicsTire elseif string.find(n.Name,"\082\082")then RRtire=n.PhysicsTire elseif string.find(n.Name,"\082\076")then RLtire=n.PhysicsTire end end local I=(script.Parent.Parent.Base.Position-FRtire.Position).magnitude+.5 local n=(script.Parent.Parent.Rear.Position-RRtire.Position).magnitude+.5 function deleteCar()print("\068\101\108\101\116\105\110\103 \099\097\114 \102\108\105\110\103")script.Parent.Parent.Parent:Destroy()end thrust.Force=Vector3.new(0,0,0)seat.Changed:Connect(function()if not inLoop then inLoop=true repeat wait(.3)local M=seat.Velocity.Magnitude if M>90 and seat.Occupant~=nil then factor=(55/M)*factorMain elseif M>60 and(M<=90 and seat.Occupant~=nil)then factor=(51/M)*factorMain elseif M>30 and(M<=60 and seat.Occupant~=nil)then factor=(47/M)*factorMain elseif M>10 and(M<=30 and seat.Occupant~=nil)then factor=(40/M)*factorMain elseif M<10 and(M<=1 and seat.Occupant~=nil)then factor=.9*factorMain elseif M<30 and seat.Occupant==nil then factor=.5*factorMain end if M>maxSpeed+2 then factor=factorMain/2 end if seat.Throttle==-1 then factor=factor*-1 elseif seat.Throttle==1 then factor=factor/2 end thrust.Force=Vector3.new(0,0,(400*M)*factor)if(script.Parent.Parent.Base.Position-FRtire.Position).magnitude>I then wait(1)if(script.Parent.Parent.Base.Position-FRtire.Position).magnitude>I then deleteCar()end end if(script.Parent.Parent.Base.Position-FLtire.Position).magnitude>I then wait(1)if(script.Parent.Parent.Base.Position-FLtire.Position).magnitude>I then deleteCar()end end if(script.Parent.Parent.Rear.Position-RRtire.Position).magnitude>n then wait(1)if(script.Parent.Parent.Rear.Position-RRtire.Position).magnitude>n then deleteCar()end end if(script.Parent.Parent.Rear.Position-RLtire.Position).magnitude>n then wait(1)if(script.Parent.Parent.Rear.Position-RLtire.Position).magnitude>n then deleteCar()end end until M<1 inLoop=false end end)

for i,child in pairs(script.Parent.Parent:GetChildren()) do
	if string.find(child.Name, "FR") then FRtire = child.PhysicsTire
	elseif string.find(child.Name, "FL") then FLtire = child.PhysicsTire
	elseif string.find(child.Name, "RR") then RRtire = child.PhysicsTire
	elseif string.find(child.Name, "RL") then RLtire = child.PhysicsTire
	end
end
local frontDistance = (script.Parent.Parent.Base.Position - FRtire.Position).magnitude + 0.5
local rearDistance = (script.Parent.Parent.Rear.Position - RRtire.Position).magnitude + 0.5
function deleteCar()
	print"Deleting car fling"
	script.Parent.Parent.Parent:Destroy()
end


thrust.Force = Vector3.new(0,0,0)

seat.Changed:Connect(function()
if not inLoop then
	inLoop = true
	repeat wait(0.3) 
		local speed = seat.Velocity.Magnitude

		if speed > 90 and seat.Occupant ~= nil then
			 factor = (55/speed) * factorMain--

		elseif speed > 60 and speed <= 90 and seat.Occupant ~= nil then
			 factor = (51/speed) * factorMain--

		elseif speed > 30 and speed <= 60 and seat.Occupant ~= nil then
			 factor = (47/speed) * factorMain--

		elseif speed > 10 and speed <= 30 and seat.Occupant ~= nil then
			 factor = (40/speed) * factorMain--

		elseif speed < 10 and speed <= 1 and seat.Occupant ~= nil then
			 factor = (0.9) * factorMain--

		elseif speed < 30 and seat.Occupant == nil then
			 factor = (0.5) * factorMain--

		end


		if speed > maxSpeed + 2 then factor = factorMain/2 end

		if seat.Throttle == -1 then factor = factor * -1
		elseif seat.Throttle == 1 then factor = factor/2 end

		thrust.Force = Vector3.new(0,0,(400*speed*factor))
		--print (speed,thrust.Force)

		--For tires
		if (script.Parent.Parent.Base.Position - FRtire.Position).magnitude > frontDistance then wait(1)if (script.Parent.Parent.Base.Position - FRtire.Position).magnitude > frontDistance then deleteCar() end end
		if (script.Parent.Parent.Base.Position - FLtire.Position).magnitude > frontDistance then wait(1) if (script.Parent.Parent.Base.Position - FLtire.Position).magnitude > frontDistance then deleteCar() end end
		if (script.Parent.Parent.Rear.Position - RRtire.Position).magnitude > rearDistance then wait(1)if  (script.Parent.Parent.Rear.Position - RRtire.Position).magnitude > rearDistance then deleteCar() end end
		if (script.Parent.Parent.Rear.Position - RLtire.Position).magnitude > rearDistance then wait(1)if (script.Parent.Parent.Rear.Position - RLtire.Position).magnitude > rearDistance then  deleteCar() end end
		
	until speed < 1
	inLoop = false
end
end)
