car.DriveSeat.ChildRemoved:connect(function(P)if P.Name=="\083\101\097\116\087\101\108\100"then car.Wheels.RL.SQ.TimeScript.Disabled=true car.Wheels.RL.SQ.PitchScript.Disabled=true car.Wheels.RR.SQ.TimeScript.Disabled=true car.Wheels.RR.SQ.PitchScript.Disabled=true car.Wheels.RL.SQ.TimePosition=0 car.Wheels.RL.SQ.Pitch=0 car.Wheels.RR.SQ.TimePosition=0 car.Wheels.RR.SQ.Pitch=0 car.Wheels.RL.Smoke.Rate=0 car.Wheels.RR.Smoke.Rate=0 end end)while wait(.2)do local P=Ray.new(car.Wheels.RL.Position,(car.Wheels.RL.Arm.CFrame*CFrame.Angles(-math.pi/2,0,0)).lookVector*(car.Wheels.RL.Size.x/1.2))local T=0 if workspace:FindPartOnRay(P,car)~=nil then T=1 end local N=Ray.new(car.Wheels.RL.Position,(car.Wheels.RR.Arm.CFrame*CFrame.Angles(-math.pi/2,0,0)).lookVector*(car.Wheels.RR.Size.x/1.2))local p=0 if workspace:FindPartOnRay(N,car)~=nil then p=1 end local b=(math.min(math.max(math.abs((car.Wheels.RL.RotVelocity.Magnitude*car.Wheels.RL.Size.x)/2-car.Wheels.RL.Velocity.Magnitude)-20,0),50)*T)*1.2 local Q=(math.min(math.max(math.abs((car.Wheels.RR.RotVelocity.Magnitude*car.Wheels.RR.Size.x)/2-car.Wheels.RR.Velocity.Magnitude)-20,0),50)*p)*1.2 car.Wheels.RL.Smoke.Rate=b car.Wheels.RR.Smoke.Rate=Q if b>1 then car.Wheels.RL.SQ.TimeScript.Disabled=false car.Wheels.RL.SQ.PitchScript.Disabled=false car.Wheels.RL.WheelFixed.Mark.Trail.Enabled=true car.Wheels.RL.WheelFixed.Mark2.Trail.Enabled=true end if b<1 then car.Wheels.RL.SQ.TimeScript.Disabled=true car.Wheels.RL.SQ.PitchScript.Disabled=true car.Wheels.RL.WheelFixed.Mark.Trail.Enabled=false car.Wheels.RL.SQ.Pitch=0 car.Wheels.RL.SQ.TimePosition=0 car.Wheels.RL.WheelFixed.Mark2.Trail.Enabled=false end if Q>1 then car.Wheels.RR.SQ.TimeScript.Disabled=false car.Wheels.RR.SQ.PitchScript.Disabled=false car.Wheels.RR.WheelFixed.Mark2.Trail.Enabled=true car.Wheels.RR.WheelFixed.Mark.Trail.Enabled=true end if Q<1 then car.Wheels.RR.SQ.TimeScript.Disabled=true car.Wheels.RR.SQ.PitchScript.Disabled=true car.Wheels.RR.SQ.Pitch=0 car.Wheels.RR.SQ.TimePosition=0 car.Wheels.RR.WheelFixed.Mark.Trail.Enabled=false car.Wheels.RR.WheelFixed.Mark2.Trail.Enabled=false end end
--This script controls the tyre mark sounds and effects like the skid marks and smoke.

car.DriveSeat.ChildRemoved:connect(function(child)
	if child.Name == "SeatWeld" then
		car.Wheels.RL.SQ.TimeScript.Disabled = true
		car.Wheels.RL.SQ.PitchScript.Disabled = true
		car.Wheels.RR.SQ.TimeScript.Disabled = true
		car.Wheels.RR.SQ.PitchScript.Disabled = true
		car.Wheels.RL.SQ.TimePosition = 0
		car.Wheels.RL.SQ.Pitch = 0
		car.Wheels.RR.SQ.TimePosition = 0
		car.Wheels.RR.SQ.Pitch = 0
		car.Wheels.RL.Smoke.Rate = 0
		car.Wheels.RR.Smoke.Rate = 0
	end
end)

while wait(0.2) do
	local r1 = Ray.new(
		car.Wheels.RL.Position,
		(car.Wheels.RL.Arm.CFrame * CFrame.Angles(-math.pi / 2, 0, 0)).lookVector * (car.Wheels.RL.Size.x / 1.2)
	)
	local r1hit = 0
	if workspace:FindPartOnRay(r1, car) ~= nil then
		r1hit = 1
	end

	local r2 = Ray.new(
		car.Wheels.RL.Position,
		(car.Wheels.RR.Arm.CFrame * CFrame.Angles(-math.pi / 2, 0, 0)).lookVector * (car.Wheels.RR.Size.x / 1.2)
	)
	local r2hit = 0
	if workspace:FindPartOnRay(r2, car) ~= nil then
		r2hit = 1
	end

	local rl = math.min(
		(
			math.max(
				math.abs(
					(car.Wheels.RL.RotVelocity.Magnitude * car.Wheels.RL.Size.x / 2) - car.Wheels.RL.Velocity.Magnitude
				) - 20,
				0
			)
		),
		50
	) * r1hit * 1.2
	local rr = math.min(
		(
			math.max(
				math.abs(
					(car.Wheels.RR.RotVelocity.Magnitude * car.Wheels.RR.Size.x / 2) - car.Wheels.RR.Velocity.Magnitude
				) - 20,
				0
			)
		),
		50
	) * r2hit * 1.2
	car.Wheels.RL.Smoke.Rate = rl
	car.Wheels.RR.Smoke.Rate = rr

	if rl > 1 then
		car.Wheels.RL.SQ.TimeScript.Disabled = false
		car.Wheels.RL.SQ.PitchScript.Disabled = false
		car.Wheels.RL.WheelFixed.Mark.Trail.Enabled = true
		car.Wheels.RL.WheelFixed.Mark2.Trail.Enabled = true
	end
	if rl < 1 then
		car.Wheels.RL.SQ.TimeScript.Disabled = true
		car.Wheels.RL.SQ.PitchScript.Disabled = true
		car.Wheels.RL.WheelFixed.Mark.Trail.Enabled = false
		car.Wheels.RL.SQ.Pitch = 0
		car.Wheels.RL.SQ.TimePosition = 0
		car.Wheels.RL.WheelFixed.Mark2.Trail.Enabled = false
	end
	if rr > 1 then
		car.Wheels.RR.SQ.TimeScript.Disabled = false
		car.Wheels.RR.SQ.PitchScript.Disabled = false

		car.Wheels.RR.WheelFixed.Mark2.Trail.Enabled = true
		car.Wheels.RR.WheelFixed.Mark.Trail.Enabled = true
	end
	if rr < 1 then
		car.Wheels.RR.SQ.TimeScript.Disabled = true
		car.Wheels.RR.SQ.PitchScript.Disabled = true
		car.Wheels.RR.SQ.Pitch = 0
		car.Wheels.RR.SQ.TimePosition = 0
		car.Wheels.RR.WheelFixed.Mark.Trail.Enabled = false
		car.Wheels.RR.WheelFixed.Mark2.Trail.Enabled = false
	end
end
