Pinkstack/roblox-luau-corpus-text huggingface dataset:
-- NOTE: This function is radically different from the engine's implementation


local walkVelocityVector = Vector3_new(1,1,1)
local function calcDesiredWalkVelocity()
	-- TEMP
	return walkVelocityVector
end

local function preStepSimulatorSide(dt)
	if getAutoJump() and enableAutoJump() then
		local desiredWalkVelocity = calcDesiredWalkVelocity();
		if (not vec3IsZero(desiredWalkVelocity)) then
			doAutoJump();
		end
	end
end

local function AutoJumper()
	local this = {}
	local running = false
	local runRoutine = nil

	function this:Run()
		running = true
		local thisRoutine = nil
		thisRoutine = coroutine.create(function()
			while running and thisRoutine == runRoutine do
				this:Step()
				task.wait()
			end
		end)
		runRoutine = thisRoutine
		coroutine.resume(thisRoutine)
	end

	function this:Stop()
		running = false
	end

	function this:Step()
		preStepSimulatorSide()
	end

	return this
end
--Automatic Settings


Tune.AutoShiftMode	= "RPM"												--[[
	[Modes]
		"Speed"		: Shifts based on wheel speed
		"RPM"		: Shifts based on RPM										]]
Tune.AutoShiftType	= "DCT"												--[[
	[Types]
		"Rev"		: Clutch engages fully once RPM reached			
		"DCT"		: Clutch engages after a set time has passed				]]
Tune.AutoUpThresh	= 200		-- Automatic upshift point 	(relative to peak RPM, positive = Over-rev)
Tune.AutoDownThresh = 1400		-- Automatic downshift point (relative to peak RPM, positive = Under-rev)
--[[
    configure(config: table): nil

    Overrides default configuration keys to change how the Dev Module behaves.

    Throws when trying to set a configuration key that does not exist.

    The possible keys and their default values for the `config` table are:

    	-- Toggle the "body orientation" feature through this parameter
    	useBodyOrientation = true,
    	
    	-- Body orientation uses a mix of waist and neck rotation, use this parameter to determine which of the two is
    	-- prevalent. It should be a number between 0 and 1: 1 means that only the waist rotates, 0 means that only the neck
    	-- rotates. A value of 0.5 performs an even mix of waist and neck rotation.
    	waistOrientationWeight = 0.5,
    	
    	-- Toggle the "chat-triggered emotes" feature through this parameter
    	useChatAnimations = true,
    	
    	-- "Chat emotes" comes with a default list of trigger words. Use this parameter to turn them off if you would rather
    	-- provide your own.
    	 useDefaultTriggerWordsForChatEmotes = true,
]]
-- Example: configures "body orientation" to make waist rotation more pronounced, and disable the "chat emotes" feature


SocialInteractions.configure({
	waistOrientationWeight = 0.75,
	useChatAnimations = false,
})
--[[for x = 1, 50 do
s.Pitch = s.Pitch + 0.01
s:play()
wait(0.04)
end]]


for x = 100, 170 do
s:play()
wait(0.04)
end
for x = 100, 210 do
s.Pitch = s.Pitch - 0.0031
s:play()
wait(0.04)
end
wait()
end
--[[			
	@param 	Number 		Range			The radius for which we will search for players (characters).
--]]


function Ownership:WaitForPlayerInRange(Range)
	-- Check if there are actually players in game - if not, wait for a player to join
	if #Players:GetPlayers() == 0 then 
		Players.PlayerAdded:Wait() 
	end
	
	local Player;
	repeat
		for _, player in pairs(Players:GetPlayers()) do
			if player and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
				if (player.Character.HumanoidRootPart.Position - self.Model.PrimaryPart.Position).Magnitude <= Range then
					Player = player
					break
				end
			end
		end
		wait(0.1)
	until Player or #Players:GetPlayers() == 0
	-- The loop waits until either a Player has been found or there are no more players left in the game.
	
	-- If no player was found, it means the other condition (no players in game) was triggered.
	if not Player then
		-- We (re-)call this method to make use of PlayerAdded:Wait() instead of a repeat-loop, for efficiency.
		self:WaitForPlayerInRange(Range)
	else
		self:SetOwner(Player)
	end
end
--Brake particles


bp1 = script.Parent.BrakeParticles1.ParticleEmitter
bp2 = script.Parent.BrakeParticles2.ParticleEmitter
bs = script.Parent.Mover.Sound --brake sound

while true do
	wait(0.1)
	--dir & speed
	if dir.Value == 0 then
		script.Parent.Mover.BodyVelocity.Velocity = Vector3.new(0, 0, 0)
	elseif dir.Value >= 0.5 then
		script.Parent.Mover.BodyVelocity.velocity= script.Parent.Mover.CFrame.lookVector*rsp.Value
	elseif dir.Value <= -0.5 then
		script.Parent.Mover.BodyVelocity.velocity= script.Parent.Mover.CFrame.lookVector*-rsp.Value
	end
	--Brake effects
	if brk.Value >= 0 and csp.Value >= 0.5 then
		bp1.Enabled = true
		bp2.Enabled = true
		bs.Volume = brk.Value / bmax.Value --this trick doesn't let the sound hurt your ears 
		                             	   --even when the maximum brake value is 10000000
	else 
		bp1.Enabled = false
		bp2.Enabled = false
		bs.Volume = 0
	end
end
-- Settings


local Configuration = Home:WaitForChild("Configuration")
local SwingPower = Configuration:WaitForChild("SwingPower")

local function SetPhysicalProperties(Part,Density)
	if Part then
		Part.CustomPhysicalProperties = PhysicalProperties.new(Density,Part.Friction,Part.Elasticity)
	end
end

GetAllDescendants = function(instance, func)
	func(instance)
	for _, child in next, instance:GetChildren() do
		GetAllDescendants(child, func)
	end
end

local function SetCharacterToWeight(ToDensity,Char)
	GetAllDescendants(Char,function(d)
		if d and d.Parent and d:IsA("BasePart") then
			SetPhysicalProperties(d,density)
		end
	end)
end

local function OnSeatChange(Seat)
	if Seat.Occupant then
		local CurrentThrottle = Seat.Throttle
		local BodyForce = Seat:WaitForChild("BodyForce")
		
		-- Adjust swing when interacted
		if CurrentThrottle == 1 then
			BodyForce.Force = Seat.CFrame.lookVector * SwingPower.Value * 100
		elseif CurrentThrottle == -1 then
			BodyForce.Force = Seat.CFrame.lookVector * SwingPower.Value * -100
		else
			BodyForce.Force = Vector3New()
		end
		
		delay(0.2,function()
			BodyForce.Force = Vector3New()
		end)
		
		-- Make the character weightless for the swing to behave correctly
		if CurrentOccupant == nil then
			CurrentOccupant = Seat.Occupant
			SetCharacterToWeight(0,CurrentOccupant.Parent)
		end
		
	elseif CurrentOccupant then
		-- Set the character's weight back
		SetCharacterToWeight(0.7,CurrentOccupant.Parent)
		CurrentOccupant = nil
	end
end

SwingSeat1.Changed:connect(function()
	OnSeatChange(SwingSeat1)
end)

SwingSeat2.Changed:connect(function()
	OnSeatChange(SwingSeat2)
end)
--[[
	Implementation
]]



local singleton = nil

local GameStageHandler = {}
GameStageHandler.__index = GameStageHandler

function GameStageHandler.new()
	local self = setmetatable({
		currentStage = nil,
		currentStageClassName = nil,
		timeStageStarted = nil,
	}, GameStageHandler)

	self.gameStageChanged = Signal.new()

	getGameStage.OnServerInvoke = function(player)
		return self.currentStageClassName
	end

	singleton = self

	return self
end

function GameStageHandler.getInstance()
	return singleton
end

function GameStageHandler:nextStage()
	-- Destroy the previous stage
	self.currentStage:destroy()

	-- Figure out what the next stage will be
	local nextStageName = nil
	for index, value in ipairs(Conf.stages) do
		if value == self.currentStageClassName then
			nextStageName = Conf.stages[index + 1]
			break
		end
	end

	self:_initializeStage(nextStageName)
end

function GameStageHandler:start()
	self:_initializeStage(Conf.stages[1])
end

function GameStageHandler:destroy()
	self.gameStageChanged = nil

	if self.currentStage then
		self.currentStage:destroy()
	end
end

function GameStageHandler:_initializeStage(stageName)
	if not stageName then
		return
	end

	print(string.format("Initilizing Stage: %s", stageName))

	-- Initialize the next stage, if there is one
	local nextStage = stageFolder:FindFirstChild(stageName)

	assert(nextStage, string.format("Failed to initialize stage \"%s\", stage does not exist", stageName))

	self.currentStage = require(nextStage).new(self)
	self.currentStageClassName = stageName
	self.timeStageStarted = tick()

	self.currentStage:initialize()

	-- Fire local event
	self.gameStageChanged:fire(stageName)

	-- Notify clients of the stage change
	gameStageChanged:FireAllClients(stageName)
	Broadcast.fireRemote("GAME_STAGE_CHANGE", stageName)
end

return GameStageHandler
--// general sound making function


function module.MakeSound(ID : string, parent : Instance, playing : boolean?, pitch : number?, volume : number?, looped : boolean?)
	local MadeSound = Instance.new("Sound")
	MadeSound.Parent = parent
	MadeSound.SoundId = ID
	MadeSound.Playing = playing
	MadeSound.PlaybackSpeed = pitch
	MadeSound.Volume = volume
	MadeSound.Looped = looped
	return MadeSound
end
--Rebirth formula secreta de las cangreRebirths :V:V:V:V:V 


Button.Activated:Connect(function()
	local FormulaUpdate = RebirthFormule.Value + (RebirthFormule.Value * Multiplier.Value)
	RebirthEvent:FireServer()
	if Points.Value >= FormulaUpdate then
		--Info for tween
	local TweenRotationInfo = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
		local Tween1 = TweenService:Create(Icon, TweenRotationInfo, {Rotation = 15})
		Tween1:Play()
		Tween1.Completed:Connect(function()
			local Tween2 = TweenService:Create(Icon, TweenRotationInfo, {Rotation = -10})
			Tween2:Play()
			Tween2.Completed:Connect(function()
				local Tween3 = TweenService:Create(Icon, TweenRotationInfo, {Rotation = 0})
				Tween3:Play()
			end)
		end)
		
	end
end)
--!strict


return {
	isFinite = require(script.isFinite),
	isInteger = require(script.isInteger),
	isNaN = require(script.isNaN),
	isSafeInteger = require(script.isSafeInteger),
	MAX_SAFE_INTEGER = require(script.MAX_SAFE_INTEGER),
	MIN_SAFE_INTEGER = require(script.MIN_SAFE_INTEGER),
	NaN = 0 / 0,
	toExponential = require(script.toExponential),
}
-- find player's head pos



	local vCharacter = Tool.Parent
	local vPlayer = game.Players:playerFromCharacter(vCharacter)

	--local head = vCharacter:findFirstChild("Head")

	local head = locateHead()
	if head == nil then return end


	--computes a the intended direction of the projectile based on where the mouse was clicked in reference to the head
	local dir = mouse_pos - head.Position
	dir = computeDirection(dir)

	local launch = head.Position + 3 * dir

	local delta = mouse_pos - launch
	
	local dy = delta.y
	
	local new_delta = Vector3.new(delta.x, 0, delta.z)
	delta = new_delta

	local dx = delta.magnitude
	local unit_delta = delta.unit
	
	-- acceleration due to gravity in RBX units
	local g = (-9.81 * 20)

	local theta = computeLaunchAngle( dx, dy, g)

	local vy = math.sin(theta)
	local xz = math.cos(theta)
	local vx = unit_delta.x * xz
	local vz = unit_delta.z * xz
	

	local missile = Pellet:clone()
        
	missile.CanCollide = true
		

	missile.Position = launch
	missile.Velocity = Vector3.new(vx,vy,vz) * VELOCITY

	missile.RotVelocity = Vector3.new(math.random(), math.random(), math.random()).unit * 10
	
	missile.OrnamentScript.Disabled = false

	local creator_tag = Instance.new("ObjectValue")
	creator_tag.Value = vPlayer
	creator_tag.Name = "creator"
	creator_tag.Parent = missile
	
	missile.Parent = game.Workspace

end

function locateHead()
	local vCharacter = Tool.Parent
	local vPlayer = game.Players:playerFromCharacter(vCharacter)

	return vCharacter:findFirstChild("Head")
end
	

function computeLaunchAngle(dx,dy,grav)
	-- arcane
	-- http://en.wikipedia.org/wiki/Trajectory_of_a_projectile
	
	local g = math.abs(grav)
	local inRoot = (VELOCITY*VELOCITY*VELOCITY*VELOCITY) - (g * ((g*dx*dx) + (2*dy*VELOCITY*VELOCITY)))
	if inRoot <= 0 then
		return .25 * math.pi
	end
	local root = math.sqrt(inRoot)
	local inATan1 = ((VELOCITY*VELOCITY) + root) / (g*dx)

	local inATan2 = ((VELOCITY*VELOCITY) - root) / (g*dx)
	local answer1 = math.atan(inATan1)
	local answer2 = math.atan(inATan2)
	if answer1 < answer2 then return answer1 end
	return answer2
end

function computeDirection(vec)
	local lenSquared = vec.magnitude * vec.magnitude
	local invSqrt = 1 / math.sqrt(lenSquared)
	return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)
end




Tool.Enabled = true
function onActivated()

	if not Tool.Enabled then
		return
	end

	Tool.Enabled = false

	local character = Tool.Parent;
	local humanoid = character.Humanoid
	if humanoid == nil then
		print("Humanoid not found")
		return 
	end

	local targetPos = humanoid.TargetPoint

	fire(targetPos)

	wait(.8)

	Tool.Enabled = true
	Tool.Handle.Transparency = 0
end

script.Parent.Activated:connect(onActivated)
--------BACKLIGHTS--------



game.Workspace.audiencebackleft1.Part1.BrickColor = BrickColor.new(194)
game.Workspace.audiencebackleft1.Part2.BrickColor = BrickColor.new(194)
game.Workspace.audiencebackleft1.Part3.BrickColor = BrickColor.new(194)
game.Workspace.audiencebackleft1.Part4.BrickColor = BrickColor.new(194)
game.Workspace.audiencebackleft1.Part5.BrickColor = BrickColor.new(194)
game.Workspace.audiencebackleft1.Part6.BrickColor = BrickColor.new(194)
game.Workspace.audiencebackleft1.Part7.BrickColor = BrickColor.new(194)
game.Workspace.audiencebackleft1.Part8.BrickColor = BrickColor.new(194)
game.Workspace.audiencebackleft1.Part9.BrickColor = BrickColor.new(194)

game.Workspace.audiencebackright1.Part1.BrickColor = BrickColor.new(194)
game.Workspace.audiencebackright1.Part2.BrickColor = BrickColor.new(194)
game.Workspace.audiencebackright1.Part3.BrickColor = BrickColor.new(194)
game.Workspace.audiencebackright1.Part4.BrickColor = BrickColor.new(194)
game.Workspace.audiencebackright1.Part5.BrickColor = BrickColor.new(194)
game.Workspace.audiencebackright1.Part6.BrickColor = BrickColor.new(194)
game.Workspace.audiencebackright1.Part7.BrickColor = BrickColor.new(194)
game.Workspace.audiencebackright1.Part8.BrickColor = BrickColor.new(194)
game.Workspace.audiencebackright1.Part9.BrickColor = BrickColor.new(194)
-- ROBLOX FIXME: Can we define ClientChatModules statically in the project config


pcall(function() ChatLocalization = require((game:GetService("Chat") :: any).ClientChatModules.ChatLocalization :: any) end)
if ChatLocalization == nil then ChatLocalization = {} end
if not ChatLocalization.FormatMessageToSend or not ChatLocalization.LocalizeFormattedMessage then
	function ChatLocalization:FormatMessageToSend(key,default) return default end
end

local FriendMessageTextColor = Color3.fromRGB(255, 255, 255)
local FriendMessageExtraData = {ChatColor = FriendMessageTextColor}

local function Run(ChatService)

	local function ShowFriendJoinNotification()
		if FFlagUserHandleFriendJoinNotifierOnClient == false then
			if ChatSettings.ShowFriendJoinNotification ~= nil then
				return ChatSettings.ShowFriendJoinNotification
			end
		end
		return false
	end

	local function SendFriendJoinNotification(player, joinedFriend)
		local speakerObj = ChatService:GetSpeaker(player.Name)
		if speakerObj then
			local joinedFriendName = joinedFriend.Name
			if ChatSettings.PlayerDisplayNamesEnabled then
				joinedFriendName = joinedFriend.DisplayName
			end

			local msg = ChatLocalization:FormatMessageToSend("GameChat_FriendChatNotifier_JoinMessage",
				string.format("Your friend %s has joined the game.", joinedFriendName),
				"RBX_NAME",
				joinedFriendName)
			speakerObj:SendSystemMessage(msg, "System", FriendMessageExtraData)
		end
	end

	local function TrySendFriendNotification(player, joinedPlayer)
		if player ~= joinedPlayer then
			coroutine.wrap(function()
				if player:IsFriendsWith(joinedPlayer.UserId) then
					SendFriendJoinNotification(player, joinedPlayer)
				end
			end)()
		end
	end

	if ShowFriendJoinNotification() then
		Players.PlayerAdded:connect(function(player)
			local possibleFriends = Players:GetPlayers()
			for i = 1, #possibleFriends do
				TrySendFriendNotification(possibleFriends[i], player)
			end
		end)
	end
end

return Run
-- Same extra's apply down here as well.



game.Players.ChildRemoved:Connect(function(player)
	if not pcall (function()
		game.StarterGui:SetCore("ChatMakeSystemMessage", {
			Text = ""..player.Name.. " has left the game.";
			Color = Color3.fromRGB(255, 151, 151);
			Font = Enum.Font.ArialBold;
			FontSize = Enum.FontSize.Size18;
		})
	end) then
		print ("Error")
	   end
end)
-- v1.0 --



local player = game.Players.LocalPlayer
local PlayButton = script.Parent.AudioPlayerGui.PlayButton
local PauseButton = script.Parent.AudioPlayerGui.PauseButton
local VolUpButton = script.Parent.AudioPlayerGui.VolUp
local VolDownButton = script.Parent.AudioPlayerGui.VolDown
local ChangeButton = script.Parent.AudioPlayerGui.ChangeButton
local onOff = script.Parent.AudioPlayerGui.onOff
local carSeat = script.Parent.CarSeat.Value
--Made by Stickmasterluke




sp=script.Parent


firerate=22
power=50
rate=1/30

debris=game:GetService("Debris")
equipped=false
check=true


function onEquipped(mouse)
	equipped=true
	if mouse~=nil then
		if check then
			mouse.Icon="rbxasset://textures\\GunCursor.png"
			sp.Handle.Transparency=0
		else
			mouse.Icon="rbxasset://textures\\GunWaitCursor.png"
			sp.Handle.Transparency=1
		end
		mouse.Button1Down:connect(function()
			local hu=sp.Parent:FindFirstChild("Humanoid")
			local t=sp.Parent:FindFirstChild("Torso")
			if check and hu and hu.Health>0 and t then
				check=false
				mouse.Icon="rbxasset://textures\\GunWaitCursor.png"
				sp.Handle.Transparency=1
				local sound=sp.Handle:FindFirstChild("Throw")
				if sound~=nil then
					sound:Play()
				end
				local shoulder=t:FindFirstChild("Right Shoulder")
				if shoulder~=nil then
					shoulder.CurrentAngle=2
				end
				local p=sp.Handle:clone()
				p.CanCollide=true
				p.Transparency=0
				local vec=(mouse.Hit.p-t.Position).unit
				p.CFrame=CFrame.new(t.Position,t.Position+vec)*CFrame.new(0,0,-5)
				p.Velocity=(vec*power)+Vector3.new(0,20,0)
				local s=script.Script:clone()
				s.Parent=p
				s.Disabled=false
				local ct=Instance.new("ObjectValue")
				ct.Name="creator"
				ct.Value=game.Players.LocalPlayer
				ct.Parent=p
				debris:AddItem(p,firerate+10)
				p.Parent=game.Workspace
				wait(firerate)
				sp.Handle.Transparency=0
				mouse.Icon="rbxasset://textures\\GunCursor.png"
				check=true
			end
		end)
	end
end

function onUnequipped()
	equipped=false
	sp.Handle.Transparency=0
end

sp.Equipped:connect(onEquipped)
sp.Unequipped:connect(onUnequipped)
--------RIGHT DOOR --------


game.Workspace.doorright.l11.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorright.l23.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorright.l32.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorright.l41.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorright.l53.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorright.l62.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorright.l71.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)

game.Workspace.doorright.pillar.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
--[[
	Creates a new alert in specified frame, of specified type. This will cause all existing alerts to move down, making room for the new one.
	The alert will disappear after a set time.
]]


function AlertController.addAlert(alerts, type, message)
	local entry = baseAlertElement:Clone()

	for _, child in pairs(alerts:GetChildren()) do
		if child:IsA("Frame") then
			child.LayoutOrder = child.LayoutOrder + 1
		end
	end

	local messageElement = entry.Message
	messageElement.Text = message

	if type == Constants.Alert.Fail then
		messageElement.TextColor3 = Color3.fromRGB(201, 67, 58)
	elseif type == Constants.Alert.Success then
		messageElement.TextColor3 = Color3.fromRGB(89, 156, 82)
	end

	entry.Parent = alerts

	delay(
		5,
		function()
			if messageElement and messageElement.Parent then
				local tween = TweenService:Create(messageElement, tweenInfo, {TextTransparency = 1})

				tween:Play()

				tween.Completed:Wait()

				entry:Destroy()
			end
		end
	)
end

return AlertController
--[[Status Vars]]



	local _IsOn = _Tune.AutoStart
	if _Tune.AutoStart then script.Parent.IsOn.Value=true end
	
	local _GSteerT=0
	local _GSteerC=0
	local _GThrot=0
	local _GBrake=0
	
	local _ClutchOn = true
	local _ClPressing = false
	local _RPM = 0
	local _HP = 0
	local _OutTorque = 0
	local _CGear = 0
	
	local _TMode = _Tune.TransModes[1]
	
	local _MSteer = false
	local _SteerL = false
	local _SteerR = false
	local _PBrake = false
	local _TCS = _Tune.TCSEnabled
	local _TCSActive = false
	local _ABS = _Tune.ABSEnabled
	local _ABSActive = false
	
	local FlipWait=tick()
	local FlipDB=false
	
	local _InControls = false
--////////////////////////////// Include
--//////////////////////////////////////


local ChatConstants = require(ReplicatedModules:WaitForChild("ChatConstants"))

local ChatChannel = require(modulesFolder:WaitForChild("ChatChannel"))
local Speaker = require(modulesFolder:WaitForChild("Speaker"))
local Util = require(modulesFolder:WaitForChild("Util"))

local ChatLocalization = nil
pcall(function() ChatLocalization = require(game:GetService("Chat").ClientChatModules.ChatLocalization) end)
ChatLocalization = ChatLocalization or {}

if not ChatLocalization.FormatMessageToSend or not ChatLocalization.LocalizeFormattedMessage then
	function ChatLocalization:FormatMessageToSend(key,default) return default end
end

local function allSpaces(inputString)
	local testString = string.gsub(inputString, " ", "")
	return string.len(testString) == 0
end
--Avxnturador @ //INSPARE


local FE = workspace.FilteringEnabled
local car = script.Parent.Car.Value
local handler = car:WaitForChild("DS_Sounds")
local lastGear = 0
local Rev1 = 1500
local Rev2 = 4000
local Rev3 = 6400
local Rev4 = 7300

wait(0.5)

script:WaitForChild("DS1")
script:WaitForChild("DS2")
script:WaitForChild("DS3")
script:WaitForChild("DS4")

for i,v in pairs(car.DriveSeat:GetChildren()) do
	for _,a in pairs(script:GetChildren()) do
		if v.Name==a.Name then v:Stop() wait() v:Destroy() end
	end
end

handler:FireServer("newSound","DS1",car.DriveSeat,script.DS1.SoundId,1,script.DS1.Volume,false)
handler:FireServer("newSound","DS2",car.DriveSeat,script.DS2.SoundId,1,script.DS2.Volume,false)
handler:FireServer("newSound","DS3",car.DriveSeat,script.DS3.SoundId,1,script.DS3.Volume,false)
handler:FireServer("newSound","DS4",car.DriveSeat,script.DS4.SoundId,1,script.DS4.Volume,false)

car.DriveSeat:WaitForChild("DS1")
car.DriveSeat:WaitForChild("DS2")
car.DriveSeat:WaitForChild("DS3")
car.DriveSeat:WaitForChild("DS4")


script.Parent.Values.Gear.Changed:connect(function()
	if lastGear>script.Parent.Values.Gear.Value then
		if ((script.Parent.Values.RPM.Value>=Rev1) and (script.Parent.Values.RPM.Value<Rev2)) then
			if FE then handler:FireServer("playSound","DS1") else car.DriveSeat.DS1:Play() end
		elseif ((script.Parent.Values.RPM.Value>=Rev2) and (script.Parent.Values.RPM.Value<Rev3)) then
			if FE then handler:FireServer("playSound","DS2") else car.DriveSeat.DS2:Play() end
		elseif ((script.Parent.Values.RPM.Value>=Rev3) and (script.Parent.Values.RPM.Value<Rev4)) then
			if FE then handler:FireServer("playSound","DS3") else car.DriveSeat.DS3:Play() end
		elseif (script.Parent.Values.RPM.Value>=Rev4) then
			if FE then handler:FireServer("playSound","DS4") else car.DriveSeat.DS4:Play() end
		end
	end
	lastGear = script.Parent.Values.Gear.Value
end)
-- Hook events


Entry.TextBox.FocusLost:Connect(function(submit)
	return Window:LoseFocus(submit)
end)

UserInputService.InputBegan:Connect(function(input, gameProcessed)
	return Window:BeginInput(input, gameProcessed)
end)

Entry.TextBox:GetPropertyChangedSignal("Text"):Connect(function()
	Gui.CanvasPosition = Vector2.new(0, Gui.AbsoluteCanvasSize.Y)

	if Entry.TextBox.Text:match("\t") then -- Eat \t
		Entry.TextBox.Text = Entry.TextBox.Text:gsub("\t", "")
		return
	end
	if Window.OnTextChanged then
		return Window.OnTextChanged(Entry.TextBox.Text)
	end
end)

Gui.ChildAdded:Connect(function()
	task.defer(Window.UpdateWindowHeight)
end)

return Window