Pinkstack/roblox-luau-corpus-text huggingface dataset:
--		print(animName .. " " .. idx .. " [" .. origRoll .. "]")


	local anim = animTable[animName][idx].anim

	-- switch animation		
	if (anim ~= currentAnimInstance) then
		
		if (currentAnimTrack ~= nil) then
			currentAnimTrack:Stop(transitionTime)
			currentAnimTrack:Destroy()
		end

		currentAnimSpeed = 1.0
	
		-- load it to the humanoid; get AnimationTrack
		currentAnimTrack = Figure.AnimationController:LoadAnimation(anim)
		 
		-- play the animation
		currentAnimTrack:Play(transitionTime)
		currentAnim = animName
		currentAnimInstance = anim

		-- set up keyframe name triggers
		if (currentAnimKeyframeHandler ~= nil) then
			currentAnimKeyframeHandler:disconnect()
		end
		currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
		
	end

end
-- Compare a packed table with a packed table of predicates.


local fmtArgs = require(script.Parent.fmtArgs)

return function(p, x)
	if p.n ~= x.n then
		local msg = "number of args in " .. fmtArgs(x) .. " does not match number of predicates"
		return false, msg
	end

	for i = 1, x.n do
		if not p[i](x[i]) then
			local msg = fmtArgs(x) .. " does not match predicates at position " .. i
			return false, msg
		end
	end
	return true
end
--[[
	Controls transparency of multiple Humanoids.
]]



local HumanoidController = require(script.Parent.HumanoidController)

local HumanoidControllers = {}
HumanoidControllers.__index = HumanoidControllers

function HumanoidControllers.new(playerList: { Player }, whitelist: { Player }?)
	local self = {
		playerList = playerList,
		whitelist = whitelist,
	}

	self.isHiding = false

	self.humanoidControllers = {}
	for _, player in ipairs(self.playerList) do
		self.humanoidControllers[player.UserId] = HumanoidController.new(player)
	end

	self.whitelistedUserIds = {}
	if self.whitelist then
		for _, player in ipairs(self.whitelist) do
			self.whitelistedUserIds[player.UserId] = true
		end
	end

	setmetatable(self, HumanoidControllers)

	return self
end

function HumanoidControllers:showHumanoids()
	self.isHiding = false
	for userId, humanoidController in pairs(self.humanoidControllers) do
		if not self.whitelistedUserIds[userId] then
			humanoidController:show()
		end
	end
end

function HumanoidControllers:hideHumanoids()
	self.isHiding = true
	for userId, humanoidController in pairs(self.humanoidControllers) do
		if not self.whitelistedUserIds[userId] then
			humanoidController:hide()
		end
	end
end

function HumanoidControllers:addHumanoidController(player: Player)
	if not self.humanoidControllers[player.UserId] then
		self.humanoidControllers[player.UserId] = HumanoidController.new(player)

		if self.isHiding then
			self.humanoidControllers[player.UserId]:hide()
		end
	else
		warn("Error: " .. player.Name .. " already has a HumanoidController.")
	end
end

function HumanoidControllers:removeHumanoidController(player: Player)
	if self.humanoidControllers[player.UserId] then
		self.humanoidControllers[player.UserId] = nil
	else
		warn("Error: " .. player.Name .. " does not have a HumanoidController to remove.")
	end
end

function HumanoidControllers:addToWhitelist(player: Player)
	if not self.whitelistedUserIds[player.UserId] then
		self.whitelistedUserIds[player.UserId] = player
	else
		warn("Error: " .. player.Name .. " is already part of the whitelist for HumanoidControllers.")
	end
end

function HumanoidControllers:removeFromWhitelist(player: Player)
	if self.whitelistedUserIds[player.UserId] ~= nil then
		self.whitelistedUserIds[player.UserId] = nil
	else
		warn("Error: " .. player.Name .. " is not part of the whitelist for HumanoidControllers.")
	end
end

function HumanoidControllers:waitForHumanoidAnimations()
	for _, humanoidController in pairs(self.humanoidControllers) do
		if humanoidController:isAnimating() then
			humanoidController.animationCompleted.Event:Wait()
		end
	end
end

return HumanoidControllers
-- Gives the player an upgrade for completing a lap


function WaypointController:ProvideLapReward()
	AddUpgradeEvent:FireServer(self.player)
end

function WaypointController:ProvideCheckpointReward()
	TouchCheckpointEvent:FireServer(self.player)
end

function WaypointController:UpdateWaypoint()
	self.waypointPath:Destroy()
	self.WaypointPathReached:Disconnect()
	self.NodeReached:Disconnect()
	self.FinishedMoving:Disconnect()
	
	if self.currentWaypointIndex == #waypoints then
		-- Player is at the last waypoint
		self.currentWaypointIndex = 1
		self.currentWaypoint = waypoints[self.currentWaypointIndex]
		self:ProvideCheckpointReward()
	else
		if self.currentWaypointIndex == 1 then			
			-- Cheer
			local animateScript = character:WaitForChild("Animate")
			local animation = animateScript:WaitForChild("cheer"):GetChildren()[1]
			if animation then
				local track = humanoid:LoadAnimation(animation)
				track.Priority = Enum.AnimationPriority.Action
				track:Play()
			end
		else
			-- Player has more waypoints left
			self:ProvideCheckpointReward()
		end
		
		self.currentWaypointIndex = self.currentWaypointIndex + 1
		self.currentWaypoint= waypoints[self.currentWaypointIndex]
	end
	
	self.waypointPath = WaypointPath.new(self.player, self.humanoidRoot.Position,
		self.currentWaypoint.Position)
	self.WaypointPathReached = self.waypointPath.WaypointReached:Connect(
		function()
			self:UpdateWaypoint()
		end)
	self.NodeReached = self.waypointPath.NodeReached:Connect(
		function()
			self._CooldownFinishedEvent:Fire()
		end)
	self.FinishedMoving = self.waypointPath.FinishedMoving:Connect(
		function()
			self:StopTracking()
		end)
	
	self.waypointPath:MoveTo()
end


return WaypointController
--//Setup//--


local WindLines = require(script.WindLines)
local WindShake = require(script.WindShake)

local WindSpeed = 20

local WindShakeSettings = {
	WindPower = 0.75,
	WindSpeed = WindSpeed,
	WindDirection = Vector3.new(5, 0, 5)
}

local WindLinesSettings = {
	WindDirection = Vector3.new(5, 0, 5),
	WindSpeed = WindSpeed,
	LifeTime = 9,
	SpawnRate = 15
}

local ShakableObjects = {
	"Leaf"
}
--// All global vars will be wiped/replaced except script



return function(data)
	local playergui = service.PlayerGui
	local localplayer = service.Player
	local toggle = script.Parent.Parent.Toggle
	
	if client.Core.Get("Chat") then
		toggle.Position = UDim2.new(1, -(45+40),1, -45)
	end
	
	toggle.MouseButton1Down:connect(function()
		local found = client.Core.Get("UserPanel",nil,true)
		if found then
			found.Object:Destroy()
		else
			client.Core.Make("UserPanel",{})
		end
	end)
	
	script.Parent.Parent.Parent = playergui
end
-- Keep a history of the past number of frames based on FRAMES_TO_CHECK_VELOCITY


local function onHeartbeat()
	local humanoidVelocity = humanoidRootPart.Velocity
	previousVelocities[counter] = humanoidVelocity

	counter = counter + 1
	if counter > MAX_VELOCITY_HISTORY_COUNT then
		counter = 1
	end

end

RunService.Heartbeat:Connect(onHeartbeat)

local function onStateChanged(oldState, newState)
	if newState == Enum.HumanoidStateType.Landed then
		local humanoidVelocity = getAverageVelocity()
		eventData:FireServer("FallDamage", humanoidVelocity)
	end
end

humanoid.StateChanged:Connect(onStateChanged)
-------- OMG HAX



r = game:service("RunService")


Tool = script.Parent

local sparkles = script.Parent.Handle:findFirstChild("Sparkles")

function onEquipped()
	menorahsound = Instance.new("Sound")
	menorahsound.SoundId = "http://www.roblox.com/asset/?id=19095020" 
	menorahsound.Parent = Tool
	menorahsound.Volume = .4

end

function onUnequipped()
	menorahsound:Stop()
end


function onActivated()

	
	--active the sparkes
	if (not sparkles.Enabled) then
		sparkles.Enabled = true		
		menorahsound:Play()
	else
		sparkles.Enabled = false
	end
end
--[ Variables ]--


local Outer = script.Parent
	local Inner = Outer:WaitForChild("Inner")
	--local Display = Outer:WaitForChild("Display")
	local Detector = Outer:WaitForChild("Detector")
	local N = Outer:WaitForChild("N")
local Player = game.Players.LocalPlayer
	local Humanoid = Player.Character:WaitForChild("Humanoid")
--[[
	Joins any number of lists together into a new list
]]


local function join(...)
	local new = {}

	for listKey = 1, select("#", ...) do
		local list = select(listKey, ...)
		local len = #new

		for itemKey = 1, #list do
			if list[itemKey] == None then
				len = len - 1
			else
				new[len + itemKey] = list[itemKey]
			end
		end
	end

	return new
end

return join
--GET THE NEEDED INFO AND PUT IN TABLES


function getwheels(model)
	for _,i in pairs (model:GetChildren()) do
		if i:IsA("BasePart") then
			i.Anchored = false
			if i.Name == "GOING" then
				table.insert(Seats,i)
			--[[	
			elseif i.Name == "Brake" then
				table.insert(Brakes,i)
				--print("Brake found")
			--]]
			end
		elseif i:IsA("Model") then
			getwheels(i)
			if i.Name == "Coupler" then
				if not cplrstr then
					cplrstr = i
				else
					FrontCoupler.model, RearCoupler.model = getclosestcoupler(cplrstr,i)
					cplrstr = nil
				end
			end
		end
	end
end

function scopinggetcoupler(model)
	local cplrs = {}
	local addtable = {}
	for _,i in pairs (model:GetChildren()) do
		if i:IsA("Model") then
			if i.Name == "Coupler" then
				table.insert(cplrs,i)
			else
				addtable = scopinggetcoupler(i)
				for _,i in pairs (addtable) do
					table.insert(cplrs,i)
				end
			end
		end
	end
	return cplrs
end

function scopinggetFront(model)
	local a = model
	if a and a.Parent then
		repeat
			a = a.Parent
		until a:FindFirstChild("Front") or a == workspace or not a.Parent
	end
	if a and a:FindFirstChild("Front") then
		return a.Front
	else
		return nil
	end
end
function scopinggetDrive(model)
	local a = model
	if a and a.Parent then
		repeat
			a = a.Parent
		until a:FindFirstChild("Drive") or a == workspace or not a.Parent
	end
	if a and a:FindFirstChild("Drive") then
		return a.Drive
	else
		return nil
	end
end

function getclosestcoupler(coupler1,coupler2)
	local tg = scopinggetFront(coupler1)
	local front, rear = nil,nil
	if coupler2 and tg then
		local dista = (coupler1.Coupler.Position-tg.Position).magnitude
		local distb = (coupler2.Coupler.Position-tg.Position).magnitude
		front = dista < distb and coupler1 or coupler2
		rear = dista < distb and coupler2 or coupler1
	elseif not coupler2 then
		front = coupler1
	end
	return front,rear
end

function updatewheels()
	for _,k in pairs (Seats) do
		k.MaxSpeed = Throttle*MAXIMUMSPEED
		k.Torque = TORQUE
		if ((k.CFrame*CFrame.new(0,0,3)).p-Front.CFrame.p).magnitude >((k.CFrame*CFrame.new(0,0,-3)).p-Front.CFrame.p).magnitude then
			k.Throttle = Reverser
		else
			k.Throttle = -Reverser
		end
	end
end
------------------------------------------------------------------------
-- reads a string
-- * has been restructured significantly compared to the original C code
------------------------------------------------------------------------



function luaX:read_string(ls, del, Token)
  self:save_and_next(ls)
  while ls.current ~= del do
    local c = ls.current
    if c == "EOZ" then
      self:lexerror(ls, "unfinished string", "TK_EOS")
    elseif self:currIsNewline(ls) then
      self:lexerror(ls, "unfinished string", "TK_STRING")
    elseif c == "\\" then
      c = self:nextc(ls)  -- do not save the '\'
      if self:currIsNewline(ls) then  -- go through
        self:save(ls, "\n")
        self:inclinenumber(ls)
      elseif c ~= "EOZ" then -- will raise an error next loop
        -- escapes handling greatly simplified here:
        local i = string.find("abfnrtv", c, 1, 1)
        if i then
          self:save(ls, string.sub("\a\b\f\n\r\t\v", i, i))
          self:nextc(ls)
        elseif not string.find(c, "%d") then
          self:save_and_next(ls)  -- handles \\, \", \', and \?
        else  -- \xxx
          c, i = 0, 0
          repeat
            c = 10 * c + ls.current
            self:nextc(ls)
            i = i + 1
          until i >= 3 or not string.find(ls.current, "%d")
          if c > 255 then  -- UCHAR_MAX
            self:lexerror(ls, "escape sequence too large", "TK_STRING")
          end
          self:save(ls, string.char(c))
        end
      end
    else
      self:save_and_next(ls)
    end--if c
  end--while
  self:save_and_next(ls)  -- skip delimiter
  Token.seminfo = string.sub(ls.buff, 2, -2)
end
--[[ Use the following script to program your on/off switch to do stuff. This can mean opening and closing a door, turning on and off lights, anything!
Just put what you want the button to do while on/off below.]]



Room = script.Parent

function on() --Type below what you want the button to do while it is on.
Room.L1.SpotLight.Enabled = true
Room.L2.SpotLight.Enabled = true
Room.L3.SpotLight.Enabled = true
Room.L4.SpotLight.Enabled = true
Room.L5.SpotLight.Enabled = true
Room.L6.SpotLight.Enabled = true
end

function off() --Type below what you want the button to do while it is off.
Room.L1.SpotLight.Enabled = false
Room.L2.SpotLight.Enabled = false
Room.L3.SpotLight.Enabled = false
Room.L4.SpotLight.Enabled = false
Room.L5.SpotLight.Enabled = false
Room.L6.SpotLight.Enabled = false
end
--[[*
 * Create a regular expression from the given regex source string.
 *
 * ```js
 * const picomatch = require('picomatch');
 * // picomatch.toRegex(source[, options]);
 *
 * const { output } = picomatch.parse('*.js');
 * console.log(picomatch.toRegex(output));
 * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
 * ```
 * @param {String} `source` Regular expression source string.
 * @param {Object} `options`
 * @return {RegExp}
 * @api public
 ]]



function picomatch.toRegex(source: string, options: Object?)
	local ok, result = pcall(function()
		local opts: Object = options or {}
		return RegExp(
			source,
			Boolean.toJSBoolean(opts.flags) and opts.flags or if Boolean.toJSBoolean(opts.nocase) then "i" else ""
		)
	end)
	if not ok then
		local err = result
		if options ~= nil and options.debug == true then
			error(err)
		end
		return RegExp("$^")
	end
	return result
end
--		print("Keyframe : ".. frameName)



		local repeatAnim = currentAnim
		-- return to idle if finishing an emote
		if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
			repeatAnim = "idle"
		end
		
		local animSpeed = currentAnimSpeed
		playAnimation(repeatAnim, 0.15, Humanoid)
		setAnimationSpeed(0.8)
	end
end
-----------------
--| Constants |--
-----------------



local BLAST_RADIUS = 20 -- Blast radius of the explosion
local BLAST_DAMAGE = 200 -- Amount of damage done to players
local BLAST_FORCE = 1200 -- Amount of force applied to parts

local IGNORE_LIST = {rocket = 1, handle = 1, effect = 1, water = 1} -- Rocket will fly through things named these
-- Skydiving


local Skydive = require(ReplicatedStorage.Skydive)

local messageTakeoverModule = require(ReplicatedStorage:WaitForChild("MessageTakeoverModule"))

Skydive.fallSpeed = 10
Skydive.fallSpeedModifier = 20
Skydive.maxHorizontalSpeed = 30
local TELEPORT_BACK_HEIGHT = -150

local SkydiveOutOfBoundsConnection = nil
--!strict
-- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential


return function(value: string | number, fractionDigits: number?): string | nil
	local num = value
	if typeof(value) == "string" then
		-- ROBLOX FIXME: add parseInt to encapsulate this logic and use it here
		local NaN = 0 / 0
		num = tonumber(value) or NaN -- works because 0 is truthy in Lua
	end
	-- returns nil for invalid input instead of nan to be more lua-native
	if typeof(num) ~= "number" then
		return "nan"
	end

	if fractionDigits ~= nil then
		if typeof(fractionDigits) ~= "number" then
			error("TypeError: fractionDigits must be a number between 0 and 100")
		end
		if fractionDigits < 0 or fractionDigits > 100 then
			error("RangeError: fractionDigits must be between 0 and 100")
		end
	end

	local formatString
	if fractionDigits == nil then
		formatString = "%e"
	else
		formatString = "%." .. tostring(fractionDigits) .. "e"
	end

	local retval = string.format(formatString, num):gsub("%+0", "+"):gsub("%-0", "-"):gsub("0*e", "e")

	return retval
end
-- functions



local function CreateSquad(name)
	if not name then
		name	= HttpService:GenerateGUID(false)
	end
	
	local squad		= script.Squad:Clone()
		squad.Name		= name
		squad.Parent	= SQUADS
		
	return squad
end

local function GetSquad(player)
	for _, squad in pairs(SQUADS:GetChildren()) do
		if squad:FindFirstChild(player.Name) then
			return squad
		end
	end
end

local function AddPlayerToSquad(player, squad)
	local playerValue	= Instance.new("ObjectValue")
		playerValue.Name	= player.Name
		playerValue.Value	= player
		playerValue.Parent	= squad
end

local function RemovePlayer(player)
	for _, squad in pairs(SQUADS:GetChildren()) do
		local playerValue	= squad:FindFirstChild(player.Name)
		
		if playerValue then
			playerValue:Destroy()
		end
	end
end
-- Build a list of valid configuration values up for debug messages.


local defaultConfigKeys = {}
for key in pairs(defaultConfig) do
	table.insert(defaultConfigKeys, key)
end

local Config = {}

function Config.new()
	local self = {}

	self._currentConfig = setmetatable({}, {
		__index = function(_, key)
			local message = (
				"Invalid global configuration key %q. Valid configuration keys are: %s"
			):format(
				tostring(key),
				table.concat(defaultConfigKeys, ", ")
			)

			error(message, 3)
		end
	})

	-- We manually bind these methods here so that the Config's methods can be
	-- used without passing in self, since they eventually get exposed on the
	-- root Roact object.
	self.set = function(...)
		return Config.set(self, ...)
	end

	self.get = function(...)
		return Config.get(self, ...)
	end

	self.scoped = function(...)
		return Config.scoped(self, ...)
	end

	self.set(defaultConfig)

	return self
end

function Config:set(configValues)
	-- Validate values without changing any configuration.
	-- We only want to apply this configuration if it's valid!
	for key, value in pairs(configValues) do
		if defaultConfig[key] == nil then
			local message = (
				"Invalid global configuration key %q (type %s). Valid configuration keys are: %s"
			):format(
				tostring(key),
				typeof(key),
				table.concat(defaultConfigKeys, ", ")
			)

			error(message, 3)
		end

		-- Right now, all configuration values must be boolean.
		if typeof(value) ~= "boolean" then
			local message = (
				"Invalid value %q (type %s) for global configuration key %q. Valid values are: true, false"
			):format(
				tostring(value),
				typeof(value),
				tostring(key)
			)

			error(message, 3)
		end

		self._currentConfig[key] = value
	end
end

function Config:get()
	return self._currentConfig
end

function Config:scoped(configValues, callback)
	local previousValues = {}
	for key, value in pairs(self._currentConfig) do
		previousValues[key] = value
	end

	self.set(configValues)

	local success, result = pcall(callback)

	self.set(previousValues)

	assert(success, result)
end

return Config
----



local GEAR_NAME = script.Parent.Name

local function GEAR_CONTROL(gear_functions)
	local GF = gear_functions
	
	--Tool variables
	local TLV = {}
	local TConnections = {}
	
	--Tool functions
	
	--Tool object functions
	local function Start()
		--forming classical tool
		TLV["Equipped"] = false
				
		TLV["Tool"] = Instance.new("Tool")
		TLV["Tool"].CanBeDropped = false
		TLV["Tool"].Name = ""
		TLV["Tool"].TextureId = "rbxassetid://"
		--TLV["Tool"].Grip = CFrame.new(0, -0.7, 0.1, 1, 0, 0, 0, 1, 0, 0, 0, 1)
		
		TLV["Handle"] = GF.GenPart()
		TLV["Handle"].Name = "Handle"
		TLV["Handle"].Parent = TLV["Tool"]
		
		--[[
		local h_mesh = Instance.new("SpecialMesh")
		h_mesh.MeshType = "FileMesh"
		h_mesh.MeshId = "rbxassetid://"
		h_mesh.TextureId = "rbxassetid://"
		h_mesh.Scale = Vector3.new(1, 1, 1)
		h_mesh.Parent = TLV["Handle"]
		--]]
		
		--[[
		TLV["Sound"] = Instance.new("Sound")
		TLV["Sound"].Volume = 1
		TLV["Sound"].SoundId = "rbxassetid://"
		TLV["Sound"].Parent = TLV["Handle"]
		--]]
		
		--adding tool to backpack
		TLV["Tool"].Parent = GF.GetBackpack()
		
		--tool triggers
		
		--tool connections
		table.insert(TConnections, TLV["Tool"].Activated:connect(function()
			if not GF.CheckAlive() then return end
			
		end))
		table.insert(TConnections, TLV["Tool"].Equipped:connect(function()
			TLV["Equipped"] = true
		end))
		table.insert(TConnections, TLV["Tool"].Unequipped:connect(function()
			TLV["Equipped"] = false
		end))
		
	end
	
	local function Update() --"return false" to destroy gear control object
		
		return true
	end
	
	local function Stop()
		if TLV["Tool"] ~= nil then
			TLV["Tool"]:Destroy()
		end
		
		for _, conn in pairs(TConnections) do
			pcall(function()
				conn:disconnect()
			end)
		end
		
		TLV = nil
	end
	
	return {Start, Update, Stop}
end

local function GEAR_EFFECT_LOCAL(gear_functions, effect_data)
	local GF = gear_functions
	local ED = effect_data --DESCRIBE EFFECT DATA VALUES BELOW
	
	--Effect variables
	local EV = {}
	
	--Client effect functions
	
	--Client effect object functions
	local function Start()
		EV["StartTime"] = tick()
		
	end
	
	local function Update(in_game) --"return false" to destroy gear effect object
		
		return true
	end
	
	local function Stop()
		EV = nil
	end
	
	return {Start, Update, Stop}
end

return {GEAR_CONTROL, GEAR_EFFECT_LOCAL}
--Gear Ratios


	Tune.FinalDrive		= 3.15	-- Gearing determines top speed and wheel torque
	Tune.Ratios			= {				-- Higher ratio = more torque, Lower ratio = higher top speed
		--[[Reverse]]	4.17		,	-- Copy and paste a ratio to add a gear
		--[[Neutral]]	0			,	-- Ratios can also be deleted
		--[[ 1 ]]		5.00		,	-- Reverse, Neutral, and 1st gear are required
		--[[ 2 ]]		3.20	,
		--[[ 3 ]]		2.14		,
		--[[ 4 ]]		1.72		,
		--[[ 5 ]]		1.31		,
		--[[ 6 ]]		1.00		,
		--[[ 7 ]]		0.82		,
		--[[ 8 ]]		0.64		,
	}
	Tune.FDMult			= 1.6	-- Ratio multiplier (Change this value instead of FinalDrive if car is struggling with torque ; Default = 1)
--[[
	Input: Player a, Player b
	Output: Bool isTeammate
	
	Returns true if the players are on the same team
--]]



return function(a, b)
	if not a or not b then return nil end
	return a and b and a:IsA'Player' and b:IsA'Player' and a.Neutral==false and b.Neutral==false and a.TeamColor==b.TeamColor
end
--[[
	Assert that our expectation value is truthy
]]


function Expectation:ok()
	local result = (self.value ~= nil) == self.successCondition

	local message = formatMessage(
		self.successCondition,
		("Expected value %q to be non-nil"):format(tostring(self.value)),
		("Expected value %q to be nil"):format(tostring(self.value))
	)

	assertLevel(result, message, 3)
	self:_resetModifiers()

	return self
end