Pinkstack/roblox-luau-corpus-text huggingface dataset:
-- connect up



function stopLoopedSounds()
	sRunning:Stop() 
	sClimbing:Stop()
	sSwimming:Stop()
end

Humanoid.Died:connect(onDied)
Humanoid.Running:connect(onRunning)
Humanoid.Swimming:connect(onSwimming)
Humanoid.Climbing:connect(onClimbing)
Humanoid.Jumping:connect(function(state) onStateNoStop(state, sJumping) prevState = "Jump" end)
Humanoid.GettingUp:connect(function(state) stopLoopedSounds() onStateNoStop(state, sGettingUp) prevState = "GetUp" end)
Humanoid.FreeFalling:connect(function(state) stopLoopedSounds() onStateFall(state, sFreeFalling) prevState = "FreeFall" end)
Humanoid.FallingDown:connect(function(state) stopLoopedSounds() onStateNoStop(state, sFallingDown) prevState = "Falling" end)
Humanoid.StateChanged:connect(function(old, new) 
	if not (new.Name == "Dead" or 
			new.Name == "Running" or 
			new.Name == "RunningNoPhysics" or 
			new.Name == "Swimming" or 
			new.Name == "Jumping" or 
			new.Name == "GettingUp" or 
			new.Name == "Freefall" or 
			new.Name == "FallingDown") then
		stopLoopedSounds()
	end
end)
--//Functions


function CheckName(Object)
	local NameFound = false
	for _,Name in pairs({"LeftFoot", "LeftHand", "LeftLowerArm", "LeftLowerLeg", "LeftUpperArm", "LeftUpperLeg", "LowerTorso", "RightFoot", "RightHand", "RightLowerArm", "RightLowerLeg", "RightUpperArm", "RightUpperLeg", "UpperTorso", "Head"}) do
		if string.lower(Object.Name) == string.lower(Name) then
			NameFound = true
		end
	end
	if NameFound then
		return true
	end
end

function AddWeld(Target, Object)
	if Target and Object then
		local Weld = Instance.new("WeldConstraint", Object)
		Weld.Part0 = Target
		Weld.Part1 = Object
	end
end

function LockPlayer(Player, Value)
	local Humanoid = Player.Character:FindFirstChildOfClass("Humanoid")
	if Player and Humanoid then
		if Value == true then
			Humanoid.PlatformStand = true
			Player.Character:FindFirstChild("HumanoidRootPart").Anchored = true
			wait(0.5)
		elseif Value == false then
			Humanoid.PlatformStand = false
			Player.Character:FindFirstChild("HumanoidRootPart").Anchored = false
		end
	end
end
-- Signal:Fire(...) implemented by running the handler functions on the
-- coRunnerThread, and any time the resulting thread yielded without returning
-- to us, that means that it yielded to the Roblox scheduler and has been taken
-- over by Roblox scheduling, meaning we have to make a new coroutine runner.


function Signal:Fire(...)
	local item = self._handlerListHead
	while item do
		if item._connected then
			if not freeRunnerThread then
				freeRunnerThread = coroutine.create(runEventHandlerInFreeThread)
				-- Get the freeRunnerThread to the first yield
				coroutine.resume(freeRunnerThread)
			end
			task.spawn(freeRunnerThread, item._fn, ...)
		end
		item = item._next
	end
end
--Scripted by DermonDarble



local character = script.Parent.Parent
local humanoid = character:WaitForChild("Humanoid")
local seat = character:WaitForChild("Seat")
local occupant = seat.Occupant

script.Parent.Parent.Seat.Changed:connect(function(property)
	if seat.Occupant ~= occupant then
		occupant = seat.Occupant
		if occupant then
			local player = game.Players:GetPlayerFromCharacter(occupant.Parent)
			if player then
				local localControlScript = script.LocalControlScript:Clone()
				localControlScript.Horse.Value = character
				localControlScript.Parent = player.PlayerGui
				localControlScript.Disabled = false
			end
		end
	end
end)
-----------------------------------------------------------
----------------------- STATIC DATA -----------------------
-----------------------------------------------------------


local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Modules = ReplicatedStorage:WaitForChild("Modules")

local DamageModule = require(Modules.DamageModule)
local Utilities = require(Modules.Utilities)
local Signal = Utilities.Signal
local table = Utilities.Table
local Thread = Utilities.Thread

local TargetEvent
if RunService:IsClient() then
	TargetEvent = RunService.RenderStepped
else
	TargetEvent = RunService.Heartbeat
end

local Projectiles = {}
local RemoveList = {}
-- Text Tools



local Equipped = 0

for i,v in pairs(Pets:GetChildren()) do
	if v.Equipped.Value == true then
		Equipped = Equipped + 1
	end
end

Data.MaxStorage:GetPropertyChangedSignal("Value"):Connect(function()
	StorageText.Text = #Pets:GetChildren() .. "/" .. Data.MaxStorage.Value
end)

Data.MaxEquip:GetPropertyChangedSignal("Value"):Connect(function()
	EquippedText.Text = Equipped .. "/" .. Data.MaxEquip.Value
end)

StorageText.Text = #Pets:GetChildren() .. "/" .. Data.MaxStorage.Value
EquippedText.Text = Equipped .. "/" .. Data.MaxEquip.Value
--[[
		___      _______                _     
	   / _ |____/ ___/ /  ___ ____ ___ (_)__ 
	  / __ /___/ /__/ _ \/ _ `(_-<(_-</ (_-<
	 /_/ |_|   \___/_//_/\_,_/___/___/_/___/
 						SecondLogic @ Inspare
]]



local car = script.Parent.Car.Value
local cam = workspace.CurrentCamera
local RS = game:GetService("RunService")

car.DriveSeat.ChildRemoved:connect(function(child)
	if child.Name=="SeatWeld" then
		RS:UnbindFromRenderStep("MCam")
		cam.CameraType = Enum.CameraType.Custom
	end
end)

script.Parent.Values.MouseSteerOn.Changed:connect(function(property)
	if script.Parent.Values.MouseSteerOn.Value then
		RS:BindToRenderStep("MCam",Enum.RenderPriority.Camera.Value,function()	
			cam.CameraType = Enum.CameraType.Scriptable
			local pspeed = math.min(1,car.DriveSeat.Velocity.Magnitude/500)
			local cc = car.DriveSeat.Position+Vector3.new(0,8+(pspeed*2),0)-(car.DriveSeat.CFrame.lookVector*17)+(car.DriveSeat.Velocity.Unit*-7*pspeed)
			cam.CoordinateFrame = CFrame.new(cc,car.DriveSeat.Position)
		end)
	else
		RS:UnbindFromRenderStep("MCam")
		cam.CameraType = Enum.CameraType.Custom
	end
end)
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
-- STATE CHANGE HANDLERS



function onRunning(speed)
	local movedDuringEmote =
		userEmoteToRunThresholdChange and currentlyPlayingEmote and Humanoid.MoveDirection == Vector3.new(0, 0, 0)
	local speedThreshold = movedDuringEmote and Humanoid.WalkSpeed or 0.75
	if speed > speedThreshold then
		local scale = 16.0
		playAnimation("walk", 0.2, Humanoid)
		setAnimationSpeed(speed / scale)
		pose = "Running"
	else
		if emoteNames[currentAnim] == nil and not currentlyPlayingEmote then
			playAnimation("idle", 0.2, Humanoid)
			pose = "Standing"
		end
	end
end

function onDied()
	pose = "Dead"
end

function onJumping()
	playAnimation("jump", 0.1, Humanoid)
	jumpAnimTime = jumpAnimDuration
	pose = "Jumping"
end

function onClimbing(speed)
	local scale = 5.0
	playAnimation("climb", 0.1, Humanoid)
	setAnimationSpeed(speed / scale)
	pose = "Climbing"
end

function onGettingUp()
	pose = "GettingUp"
end

function onFreeFall()
	if (jumpAnimTime <= 0) then
		playAnimation("fall", fallTransitionTime, Humanoid)
	end
	pose = "FreeFall"
end

function onFallingDown()
	pose = "FallingDown"
end

function onSeated()
	pose = "Seated"
end

function onPlatformStanding()
	pose = "PlatformStanding"
end
--Made by Luckymaxer



Players = game:GetService("Players")
Debris = game:GetService("Debris")

RbxUtility = LoadLibrary("RbxUtility")
Create = RbxUtility.Create

Character = script.Parent
Humanoid = Character:FindFirstChild("Humanoid")

Player = Players:GetPlayerFromCharacter(Character)

Fire = script:WaitForChild("Fire")

Creator = script:FindFirstChild("Creator")

Removing = false
Flames = {}

function DestroyScript()
	if Removing then
		return
	end
	Removing = true
	if Humanoid then
		Humanoid.WalkSpeed = 16
	end
	for i, v in pairs(Flames) do
		v.Enabled = false
		Debris:AddItem(v, 2)
	end
	Debris:AddItem(script, 1)
end

function IsTeamMate(Player1, Player2)
	return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
end

function TagHumanoid(humanoid, player)
	local Creator_Tag = Create("ObjectValue"){
		Name = "creator",
		Value = player,
	}
	Debris:AddItem(Creator_Tag, 2)
	Creator_Tag.Parent = humanoid
end

function UntagHumanoid(humanoid)
	for i, v in pairs(humanoid:GetChildren()) do
		if v:IsA("ObjectValue") and v.Name == "creator" then
			v:Destroy()
		end
	end
end

function GetCreator()
	return (((Creator and Creator.Value and Creator.Value.Parent and Creator.Value:IsA("Player")) and Creator.Value) or nil)
end

CreatorPlayer = GetCreator()

if not Humanoid or Humanoid.Health == 0 or not CreatorPlayer then
	DestroyScript()
	return
end

Humanoid.WalkSpeed = 8

for i, v in pairs(Character:GetChildren()) do
	if v:IsA("BasePart") then
		local Flame = Fire:Clone()
		Flame.Enabled = true
		table.insert(Flames, Flame)
		Flame.Parent = v
	end
end

for i = 1, 5 do
	wait(1.5)
	if not Player or (Player and not IsTeamMate(Player, CreatorPlayer)) then
		UntagHumanoid(Humanoid)
		TagHumanoid(Humanoid, Player)
		Humanoid:TakeDamage(5)
	end
end

DestroyScript()
-- Editable Values


local ExhaustId = 5937167081
local EngineId = 6002661882
local IdleId = 5226685480
local RedlineId = 5070456793

local ExhaustVol = .5
local ExhaustRollOffMax = 1000
local ExhaustRollOffMin = 10
local ExhaustVolMult = 1.05

local EngineVol = .05
local EngineRollOffMax = 1000
local EngineRollOffMin = 15
local EngineVolMult = 1.25

local IdleVol = 1
local IdleRollOffMax = 1000
local IdleRollOffMin = 5
local IdleRPMScale = 1500

local RedlineVol = .5
local RedlineRollOffMax = 1000
local RedlineRollOffMin = 5

local ExhaustPitch = .3
local EnginePitch = .5
local ExhaustRev = 1
local EngineRev = .8

local ExhaustEqualizer = {0,4,6}
local EngineEqualizer = {0,4,6}

local ExhaustDecelEqualizer = {-25,0,5}
local EngineDecelEqualizer = {-25,0,5}

local ThrottleVolMult = .5
local ThrottlePitchMult = .1

local ExhaustDistortion = .0
local ExhaustRevDistortion = .3
local EngineDistortion = .2
local EngineRevDistortion = .5

local FE=true
--------END LIGHTED RECTANGLES--------
--------SIDE DOOR--------



game.Workspace.rightsidedoor.l1.BrickColor = BrickColor.new(194)
game.Workspace.rightsidedoor.l2.BrickColor = BrickColor.new(194)
game.Workspace.rightsidedoor.l3.BrickColor = BrickColor.new(194)
game.Workspace.rightsidedoor.l4.BrickColor = BrickColor.new(194)
game.Workspace.rightsidedoor.l5.BrickColor = BrickColor.new(194)
--Automatic Gauge Scaling


if autoscaling then
	local Drive={}
	if _Tune.Config == "FWD" or _Tune.Config == "AWD" then
		if car.Wheels:FindFirstChild("FL")~= nil then
			table.insert(Drive,car.Wheels.FL)
		end
		if car.Wheels:FindFirstChild("FR")~= nil then
			table.insert(Drive,car.Wheels.FR)
		end
		if car.Wheels:FindFirstChild("F")~= nil then
			table.insert(Drive,car.Wheels.F)
		end
	end
	if _Tune.Config == "RWD" or _Tune.Config == "AWD" then
		if car.Wheels:FindFirstChild("RL")~= nil then
			table.insert(Drive,car.Wheels.RL)
		end
		if car.Wheels:FindFirstChild("RR")~= nil then
			table.insert(Drive,car.Wheels.RR)
		end
		if car.Wheels:FindFirstChild("R")~= nil then
			table.insert(Drive,car.Wheels.R)
		end
	end

	local wDia = 0
	for i,v in pairs(Drive) do
		if v.Size.x>wDia then wDia = v.Size.x end
	end
	Drive = nil
	for i,v in pairs(UNITS) do
		v.maxSpeed = math.ceil(v.scaling*wDia*math.pi*_lRPM/60/_Tune.Ratios[#_Tune.Ratios]/_Tune.FinalDrive)
		v.spInc = math.max(math.ceil(v.maxSpeed/200)*20,20)
	end
end

local lns = Instance.new("Frame",script.Parent.Speedo)
lns.Name = "lns"
lns.BackgroundTransparency = 1
lns.BorderSizePixel = 0
lns.Size = UDim2.new(0,0,0,0)
for i=1,90 do
	local ln = script.Parent.ln:clone()
	ln.Parent = lns
	ln.Rotation = 45 + 225*(i/90)
	if i%2==0 then
		ln.Frame.Size = UDim2.new(0,2,0,10)
		ln.Frame.Position = UDim2.new(0,-1,0,100)
	else
		ln.Frame.Size = UDim2.new(0,3,0,5)
	end
	ln.Num:Destroy()
	ln.Visible=false
end

for i,v in pairs(UNITS) do
	local lnn = Instance.new("Frame",script.Parent.Speedo)
	lnn.BackgroundTransparency = 1
	lnn.BorderSizePixel = 0
	lnn.Size = UDim2.new(0,0,0,0)
	lnn.Name = v.units
	if i~= 1 then lnn.Visible=false end
	
	for i=0,v.maxSpeed,v.spInc do
		local ln = script.Parent.ln:clone()
		ln.Parent = lnn
		ln.Rotation = 45 + 225*(i/v.maxSpeed)
		ln.Num.Text = i
		ln.Num.TextSize = 14
		ln.Num.Rotation = -ln.Rotation
		ln.Frame:Destroy()
		ln.Num.Visible=true
		ln.Visible=false
	end
end





script.Parent.Parent.Values.Gear.Changed:connect(function()
	local gearText = script.Parent.Parent.Values.Gear.Value
	if gearText == 0 then gearText = "N" end
	if gearText == -1 then gearText = "R" end
	script.Parent.Gear.Text = "Gear : "..gearText.." / 6"
	end)
	

local UIS = game:GetService("UserInputService")
L = false
UIS.InputBegan:connect(function(i,GP) if not GP then if i.KeyCode == Enum.KeyCode.Z then
if L == false then
script.Parent.Left.ImageColor3 = Color3.fromRGB(142, 255, 169)
L = true
else
script.Parent.Left.ImageColor3 = Color3.fromRGB(255,255,255)
L = false
end
end end end)
--[[Engine]]


	--Torque Curve
	Tune.Horsepower		= 274		--	[TORQUE CURVE VISUAL]
	Tune.IdleRPM		= 700		--		https://www.desmos.com/calculator/2uo3hqwdhf
	Tune.PeakRPM		= 6500		--		Use sliders to manipulate values
	Tune.Redline		= 8000		--		Copy and paste slider values into the respective tune values
	Tune.EqPoint		= 6500
	Tune.PeakSharpness	= 7.5
	Tune.CurveMult		= 0.16
	
	--Incline Compensation
	Tune.InclineComp	= 1.7			-- Torque compensation multiplier for inclines (applies gradient from 0-90 degrees)
	
	--Misc
	Tune.RevAccel		= 100		-- RPM acceleration when clutch is off
	Tune.RevDecay		= 75		-- RPM decay when clutch is off
	Tune.RevBounce		= 500		-- RPM kickback from redline
	Tune.IdleThrottle	= 3			-- Percent throttle at idle
	Tune.ClutchTol		= 500		-- Clutch engagement threshold (higher = faster response)
-- Keep current player updated in tool mode


if ToolMode == 'Tool' then

	-- Set current player if in backpack
	if Tool.Parent and Tool.Parent:IsA 'Backpack' then
		Player = Tool.Parent.Parent;

	-- Set current player if in character
	elseif Tool.Parent and Tool.Parent:IsA 'Model' then
		Player = Players:GetPlayerFromCharacter(Tool.Parent);

	-- Clear `Player` if not in possession of a player
	else
		Player = nil;
	end;

	-- Stay updated with latest player operating the tool
	Tool.AncestryChanged:Connect(function (Child, Parent)

		-- Ensure tool's parent changed
		if Child ~= Tool then
			return;
		end;

		-- Set `Player` to player of the backpack the tool is in
		if Parent and Parent:IsA 'Backpack' then
			Player = Parent.Parent;

		-- Set `Player` to player of the character holding the tool
		elseif Parent and Parent:IsA 'Model' then
			Player = Players:GetPlayerFromCharacter(Parent);

		-- Clear `Player` if tool is not parented to a player
		else
			Player = nil;
		end;

	end);

end;
--// # key, ManOff


mouse.KeyUp:connect(function(key)
	if key=="h" then 
		veh.Lightbar.middle.Man:Stop()
		veh.Lightbar.middle.Wail.Volume = 2
		veh.Lightbar.middle.Yelp.Volume = 2
		veh.Lightbar.middle.Priority.Volume = 2
		script.Parent.Parent.Sirens.Man.BackgroundColor3 = Color3.fromRGB(62, 62, 62)
	end
end)
-------------------Weapons-------------------


if(key == "z") then
show_ammo = true
end  

if(key == keys.minigun) and on then 
		minigun_shoot = true
		while minigun_shoot do
		if(minigun.left ~= 0) then
		getBullet("GunA") 
		minigun.left = minigun.left -1
		end 
		if(minigun.right ~= 0) then
		getBullet("GunB")
		minigun.right = minigun.right -1
		end 
		wait(shoot_rate)
		end
end 
	
if(key == "f") and  on then
		if(missile_side == 1) then
				if(hydra.right ~= 0) then 
					Getmissile("LaunchB")
					missile_side = 2
				end
		elseif(missile_side == 2) then
				if(hydra.left ~= 0) then 
					Getmissile("LaunchA")
					missile_side = 1
				end
		end
end
-- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote


local emoteNames = { wave = false, point = false, dance = true, dance2 = true, dance3 = true, laugh = false, cheer = false}

math.randomseed(tick())

function findExistingAnimationInSet(set, anim)
	if set == nil or anim == nil then
		return 0
	end
	
	for idx = 1, set.count, 1 do 
		if set[idx].anim.AnimationId == anim.AnimationId then
			return idx
		end
	end
	
	return 0
end

function configureAnimationSet(name, fileList)
	if (animTable[name] ~= nil) then
		for _, connection in pairs(animTable[name].connections) do
			connection:disconnect()
		end
	end
	animTable[name] = {}
	animTable[name].count = 0
	animTable[name].totalWeight = 0	
	animTable[name].connections = {}

	local allowCustomAnimations = true

	local success, msg = pcall(function() allowCustomAnimations = game:GetService("StarterPlayer").AllowCustomAnimations end)
	if not success then
		allowCustomAnimations = true
	end

	-- check for config values
	local config = script:FindFirstChild(name)
	if (allowCustomAnimations and config ~= nil) then
		table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
		table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
		
		local idx = 0
		for _, childPart in pairs(config:GetChildren()) do
			if (childPart:IsA("Animation")) then
				local newWeight = 1
				local weightObject = childPart:FindFirstChild("Weight")
				if (weightObject ~= nil) then
					newWeight = weightObject.Value
				end
				animTable[name].count = animTable[name].count + 1
				idx = animTable[name].count
				animTable[name][idx] = {}
				animTable[name][idx].anim = childPart
				animTable[name][idx].weight = newWeight
				animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
				table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
				table.insert(animTable[name].connections, childPart.ChildAdded:connect(function(property) configureAnimationSet(name, fileList) end))
				table.insert(animTable[name].connections, childPart.ChildRemoved:connect(function(property) configureAnimationSet(name, fileList) end))
			end
		end
	end
	
	-- fallback to defaults
	if (animTable[name].count <= 0) then
		for idx, anim in pairs(fileList) do
			animTable[name][idx] = {}
			animTable[name][idx].anim = Instance.new("Animation")
			animTable[name][idx].anim.Name = name
			animTable[name][idx].anim.AnimationId = anim.id
			animTable[name][idx].weight = anim.weight
			animTable[name].count = animTable[name].count + 1
			animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
		end
	end
	
	-- preload anims
	for i, animType in pairs(animTable) do
		for idx = 1, animType.count, 1 do
			if PreloadedAnims[animType[idx].anim.AnimationId] == nil then
				Humanoid:LoadAnimation(animType[idx].anim)
				PreloadedAnims[animType[idx].anim.AnimationId] = true
			end				
		end
	end
end
--Weld stuff here
--Wipers


MakeWeld(misc.Wiper.H1,car.DriveSeat)
MakeWeld(misc.Wiper.H2,car.DriveSeat)
ModelWeld(misc.Wiper.Parts1,misc.Wiper.H1)
ModelWeld(misc.Wiper.Parts2,misc.Wiper.H2)
--Double Jump Fly


local character = main.player.Character or main.player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local eventsModule = main:GetModule("Events")
if main.device ~= "Computer" then
	local bindable = eventsModule:New("DoubleJumped", humanoid)
	bindable.Event:Connect(function()
		for speedCommandName, _ in pairs(main.commandSpeeds) do
			if main.commandsActive[speedCommandName] then
				main:GetModule("cf"):EndCommand(speedCommandName)
			else
				main:GetModule("cf"):ActivateClientCommand(speedCommandName)
			end
		end
	end)
end



return module
--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(.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
--[[
	An internal method used by the reconciler to construct a new component
	instance and attach it to the given virtualNode.
]]


function Component:__mount(reconciler, virtualNode)
	if config.internalTypeChecks then
		internalAssert(Type.of(self) == Type.StatefulComponentClass, "Invalid use of `__mount`")
		internalAssert(Type.of(virtualNode) == Type.VirtualNode, "Expected arg #2 to be of type VirtualNode")
	end

	local currentElement = virtualNode.currentElement
	local hostParent = virtualNode.hostParent

	-- Contains all the information that we want to keep from consumers of
	-- Roact, or even other parts of the codebase like the reconciler.
	local internalData = {
		reconciler = reconciler,
		virtualNode = virtualNode,
		componentClass = self,
		lifecyclePhase = ComponentLifecyclePhase.Init,
	}

	local instance = {
		[Type] = Type.StatefulComponentInstance,
		[InternalData] = internalData,
	}

	setmetatable(instance, self)

	virtualNode.instance = instance

	local props = currentElement.props

	if self.defaultProps ~= nil then
		props = assign({}, self.defaultProps, props)
	end

	instance:__validateProps(props)

	instance.props = props

	local newContext = assign({}, virtualNode.legacyContext)
	instance._context = newContext

	instance.state = assign({}, instance:__getDerivedState(instance.props, {}))

	if instance.init ~= nil then
		instance:init(instance.props)
		assign(instance.state, instance:__getDerivedState(instance.props, instance.state))
	end

	-- It's possible for init() to redefine _context!
	virtualNode.legacyContext = instance._context

	internalData.lifecyclePhase = ComponentLifecyclePhase.Render
	local renderResult = instance:render()

	internalData.lifecyclePhase = ComponentLifecyclePhase.ReconcileChildren
	reconciler.updateVirtualNodeWithRenderResult(virtualNode, hostParent, renderResult)

	if instance.didMount ~= nil then
		internalData.lifecyclePhase = ComponentLifecyclePhase.DidMount
		instance:didMount()
	end

	if internalData.pendingState ~= nil then
		-- __update will handle pendingState, so we don't pass any new element or state
		instance:__update(nil, nil)
	end

	internalData.lifecyclePhase = ComponentLifecyclePhase.Idle
end