Pinkstack/roblox-luau-corpus-text huggingface dataset:
--[=[
	Mounts Blend objects into an existing instance.

	:::tip
	Normally specifying ClassName as a property breaks mounting, since you
	can't write to ClassName. However, if you specify ClassName here, it will only
	listen to changes on children with that class name.
	:::

	If multiple instances are named the same thing, then this will
	bind to both.

	:::tip
	This explicitly listens for any children underneath the mounted
	instance with the name passed in here. This is fine for small amounts
	of instances, like in most Gui hierarchies. However, it will be way less
	performance friendly for large class hierarchies.
	:::

	```lua
	maid:GiveTask(Blend.mount(frame, {
		Size = UDim2.new(0.5, 0, 0.5, 0);

		Blend.Find "MyUIScaleName" {
			Scale = 2;
		};
	}))
	```

	@param name string
	@return function
]=]


function Blend.Find(name)
	assert(type(name) == "string", "Bad name")

	return function(props)
		assert(type(props) == "table", "Bad props")

		local mountProps = props
		local className
		if props.ClassName then
			className = props.ClassName
			mountProps = table.clone(props)
			mountProps.ClassName = nil
		else
			className = "Instance"
		end

		return function(parent)
			return RxInstanceUtils.observeChildrenOfNameBrio(parent, className, name):Pipe({
				Rx.flatMap(function(brio)
					if brio:IsDead() then
						return
					end

					local maid = brio:ToMaid()
					local instance = brio:GetValue()
					maid:GiveTask(Blend.mount(instance, mountProps))

					-- Dead after mounting? Clean up...
					-- Probably caused by name change.
					if brio:IsDead() then
						maid:DoCleaning()
					end

					-- Avoid emitting anything else so we don't get cleaned up
					return Rx.EMPTY
				end);
			})
		end
	end
end
-- (Giver - Loaded.)



debounce = true

function onTouched(hit)
	if (hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == true) then
		debounce = false
		h = Instance.new("Hat")
		p = Instance.new("Part")
		h.Name = "Snake Eyes"
		p.Parent = h
		p.Position = hit.Parent:findFirstChild("Head").Position
		p.Name = "Handle" 
		p.formFactor = 0
		p.Size = Vector3.new(1, 1, 2) 
		p.BottomSurface = 0 
		p.TopSurface = 0 
		p.Locked = true 
		script.Parent.Mesh:clone().Parent = p
		h.Parent = hit.Parent
		h.AttachmentForward = Vector3.new (-0, -0, -1)
		h.AttachmentPos = Vector3.new(0, -0.05, 0)
		h.AttachmentRight = Vector3.new (1, 0, 0)
		h.AttachmentUp = Vector3.new (0, 1, 0)
		wait(5)
		debounce = true
	end
end

script.Parent.Touched:connect(onTouched)
-- print("Деревьев: ",xix)


	local primary = model.PrimaryPart
	local primaryCf = primary.CFrame	
	for _,v in pairs(model:GetDescendants()) do
		if (v:IsA("BasePart")) then
			v.Size = (v.Size * scale)
			if (v ~= primary) then
				v.CFrame = (primaryCf + (primaryCf:inverse() * v.Position * scale))
			end
		end
	end	
	return model
end
local function spawnTree(pos)
	if rnd:NextInteger(1,10000) <= TREE_SCALE*100 then
		-- сажаем
		local mm=rnd:NextInteger(1,#tree)
		
		local co=tree[mm]
		local ct=co:Clone()
		ct=ScaleModel(ct,rnd:NextNumber(0.5,2))-- изменение размеров
		ct.Parent = game.Workspace.Tree
		ct.Name = "Tree " .. tostring(ct)
		
		local cx=pos.X
		local cz=pos.Z
		local cy=pos.y
		
		ct:SetPrimaryPartCFrame(CFrame.new(cx, cy + ct.PrimaryPart.Size.Y*0.5, cz)) -- переместить
		ct:SetPrimaryPartCFrame(ct:GetPrimaryPartCFrame() * CFrame.Angles(0, rnd:NextInteger(0,360), 0)) -- повернуть
	end 
end


local chunks = {}

local function chunkExists(chunkX, chunkZ)
	if not chunks[chunkX] then
		chunks[chunkX] = {}
	end
	return chunks[chunkX][chunkZ]
end
--[[
	Plays any relevant status related sound
]]


function VehicleSoundComponent:updateStatus(statusChanged)
	if statusChanged.Crashed and statusChanged.Crashed == true then
		local crashSound = CarSoundsFolder.Crashed[tonumber(math.random(1, 3))]:Clone()

		-- Parent then destroy it to play at that location
		crashSound.Parent = self.model.PrimaryPart
		crashSound:Play()
		Debris:AddItem(crashSound, 3)
	end

	if statusChanged.SharpTurn ~= nil then
		if statusChanged.SharpTurn == true and self.controller:getSpeed() > 80 then
			TweenService:Create(self.skid, tweenInfo, {Volume = 0.5}):Play()
		else
			TweenService:Create(self.skid, tweenInfo, {Volume = 0}):Play()
		end
	end

	if statusChanged.Boost ~= nil then
		if statusChanged.Boost then
			TweenService:Create(self.boost, tweenInfo, {Volume = 0.5}):Play()
		else
			TweenService:Create(self.boost, tweenInfo, {Volume = 0}):Play()
		end
	end
end

return VehicleSoundComponent
--Public functions



function DataStore:Get(defaultValue, dontAttemptGet)
	if dontAttemptGet then
		return self.value
	end

	local backupCount = 0

	if not self.haveValue then
		while not self.haveValue do
			local success, error = self:_GetRaw():await()

			if not success then
				if self.backupRetries then
					backupCount = backupCount + 1

					if backupCount >= self.backupRetries then
						self.backup = true
						self.haveValue = true
						self.value = self.backupValue
						break
					end
				end

				self:Debug("Get returned error:", error)
			end
		end

		if self.value ~= nil then
			for _, modifier in ipairs(self.beforeInitialGet) do
				self.value = modifier(self.value, self)
			end
		end
	end

	local value

	if self.value == nil and defaultValue ~= nil then --not using "not" because false is a possible value
		value = defaultValue
	else
		value = self.value
	end

	value = clone(value)

	self.value = value

	return value
end

function DataStore:GetAsync(...)
	return Promise.promisify(function(...)
		return self:Get(...)
	end)(...)
end

function DataStore:GetTable(default, ...)
	local success, result = self:GetTableAsync(default, ...):await()
	if not success then
		error(result)
	end
	return result
end

function DataStore:GetTableAsync(default, ...)
	assert(default ~= nil, "You must provide a default value.")

	return self:GetAsync(default, ...):andThen(function(result)
		local changed = false
		assert(
			typeof(result) == "table",
			":GetTable/:GetTableAsync was used when the value in the data store isn't a table."
		)

		for defaultKey, defaultValue in pairs(default) do
			if result[defaultKey] == nil then
				result[defaultKey] = defaultValue
				changed = true
			end
		end

		if changed then
			self:Set(result)
		end

		return result
	end)
end

function DataStore:Set(value, _dontCallOnUpdate)
	self.value = clone(value)
	self:_Update(_dontCallOnUpdate)
end

function DataStore:Update(updateFunc)
	self.value = updateFunc(self.value)
	self:_Update()
end

function DataStore:Increment(value, defaultValue)
	self:Set(self:Get(defaultValue) + value)
end

function DataStore:IncrementAsync(add, defaultValue)
	return self:GetAsync(defaultValue):andThen(function(value)
		return Promise.promisify(function()
			self:Set(value + add)
		end)()
	end)
end

function DataStore:OnUpdate(callback)
	table.insert(self.callbacks, callback)
end

function DataStore:BeforeInitialGet(modifier)
	table.insert(self.beforeInitialGet, modifier)
end

function DataStore:BeforeSave(modifier)
	self.beforeSave = modifier
end

function DataStore:AfterSave(callback)
	table.insert(self.afterSave, callback)
end
-- METHODS


function Signal:Fire(...)
	for _, connection in pairs(self.connections) do
		--connection.Handler(...)
		task.spawn(connection.Handler, ...)
	end
	if self.totalWaiting > 0 then
		local packedArgs = table.pack(...)
		for waitingId, _ in pairs(self.waiting) do
			self.waiting[waitingId] = packedArgs
		end
	end
end
Signal.fire = Signal.Fire

function Signal:Connect(handler)
	if not (type(handler) == "function") then
		error(("connect(%s)"):format(typeof(handler)), 2)
	end
	
	local signal = self
	local connectionId = HttpService:GenerateGUID(false)
	local connection = {}
	connection.Connected = true
	connection.ConnectionId = connectionId
	connection.Handler = handler
	self.connections[connectionId] = connection

	function connection:Disconnect()
		signal.connections[connectionId] = nil
		connection.Connected = false
		signal.totalConnections -= 1
		if signal.connectionsChanged then
			signal.connectionsChanged:Fire(-1)
		end
	end
	connection.Destroy = connection.Disconnect
	connection.destroy = connection.Disconnect
	connection.disconnect = connection.Disconnect
	self.totalConnections += 1
	if self.connectionsChanged then
		self.connectionsChanged:Fire(1)
	end

	return connection
end
Signal.connect = Signal.Connect

function Signal:Wait()
	local waitingId = HttpService:GenerateGUID(false)
	self.waiting[waitingId] = true
	self.totalWaiting += 1
	repeat heartbeat:Wait() until self.waiting[waitingId] ~= true
	self.totalWaiting -= 1
	local args = self.waiting[waitingId]
	self.waiting[waitingId] = nil
	return unpack(args)
end
Signal.wait = Signal.Wait

function Signal:Destroy()
	if self.bindableEvent then
		self.bindableEvent:Destroy()
		self.bindableEvent = nil
	end
	if self.connectionsChanged then
		self.connectionsChanged:Fire(-self.totalConnections)
		self.connectionsChanged:Destroy()
		self.connectionsChanged = nil
	end
	self.totalConnections = 0
	for connectionId, connection in pairs(self.connections) do
		self.connections[connectionId] = nil
	end
end
Signal.destroy = Signal.Destroy
Signal.Disconnect = Signal.Destroy
Signal.disconnect = Signal.Destroy



return Signal
--[[
	Handles the PurchasingSeed stage during the First Time User Experience,
	which waits for the player to purchase a seed
--]]



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

local FarmManagerServer = require(ServerStorage.Source.Farm.FarmManagerServer)
local Market = require(ServerStorage.Source.Market)
local FtueStage = require(ReplicatedStorage.Source.SharedConstants.FtueStage)
local ItemCategory = require(ReplicatedStorage.Source.SharedConstants.ItemCategory)

local PurchasingSeedFtueStage = {}

function PurchasingSeedFtueStage.handleAsync(player: Player): FtueStage.EnumType?
	local farm = FarmManagerServer.getFarmForPlayer(player)
	farm:openDoor()

	repeat
		local playerWhoBought, _, itemCategory = Market.itemsPurchased:Wait()
	until playerWhoBought == player and itemCategory == ItemCategory.Seeds

	return FtueStage.PurchasingPot
end

return PurchasingSeedFtueStage
----[UPDATE SLIDERS WHEN GUI SIZE X CHANGES]----


local function ResizeSlider()
	if PluginGui.AbsoluteSize.X ~= PreviousSizeX then
		PreviousSizeX = Plugin.AbsoluteSize.X
		for i = 1,	#ColorPickers do
			UpdateRGBSliders(i)
		end
	end
end
PluginGui.Changed:Connect(ResizeSlider)
-- Lewin4 2020/10/20
-- last edited 2020/10/20



local vat = script.Parent
local teles = game.workspace.teles

local function steppedOn(part)
	local parent = part.Parent
	if game.Players:GetPlayerFromCharacter(parent) then
		
		wait(0.5)
		
		parent.HumanoidRootPart.Position = vat.Position
		
		parent.HumanoidRootPart.Position = teles.tele1.Position
	end

end

vat.Touched:connect(steppedOn)
-- Create smoke for specified part (being destroyed)	


local function createSmoke(targetPart)
	local pos = Vector3.new(0, 0, 0)
	local size = 3
	if targetPart:IsA("Model") and targetPart.PrimaryPart then
		--local plate = targetPart:FindFirstChild("Plate", true)
		local plate = targetPart.PrimaryPart
		pos = plate.Position
		size = 1*plate.Size.X
	else
		pos = targetPart.Position
		size = 1*targetPart.Size.X
	end	
	
	local smokePart = Instance.new("Part")
	smokePart.Name = "SmokePart"
	smokePart.Transparency = 1
	smokePart.CanCollide = false
	smokePart.Anchored = true
	--smokePart.Position = getPositionRelativetoBase(smokePart, pos) + Vector3.new(0, 1, 0)
	smokePart.Position = pos + Vector3.new(0, 1, 0)
	smokePart.Size = Vector3.new(1, 1, 1)
	smokePart.Parent = mapManager.getMap()
	
	local crushSound
	local randomNum = math.random(1,3)
	if randomNum == 1 then
		crushSound = ServerStorage.CrushSound1:Clone()
	elseif randomNum == 2 then
		crushSound = ServerStorage.CrushSound2:Clone()
	elseif randomNum == 3 then
		crushSound = ServerStorage.CrushSound3:Clone()
	end
	crushSound.Parent = smokePart
	if not crushSound.IsLoaded then
		crushSound.Loaded:wait()
	end
	crushSound:Play()

	local smoke = Instance.new("Smoke")
	smoke.Parent = smokePart
	smoke.RiseVelocity = 0
	smoke.Size = size

	DebrisService:AddItem(smokePart, 2)
end
--[[

	streamable = Streamable.new(parent: Instance, childName: string)

	streamable:Observe(handler: (child: Instance, janitor: Janitor) -> void): Connection
	streamable:Destroy()

--]]



type StreamableWithInstance = {
	Instance: Instance?,
	[any]: any,
}

local Janitor = require(script.Parent.Janitor)
local Signal = require(script.Parent.Signal)


local Streamable = {}
Streamable.__index = Streamable


function Streamable.new(parent: Instance, childName: string)

	local self: StreamableWithInstance = {}
	setmetatable(self, Streamable)

	self._janitor = Janitor.new()
	self._shown = Signal.new(self._janitor)
	self._shownJanitor = Janitor.new()
	self._janitor:Add(self._shownJanitor)

	self.Instance = parent:FindFirstChild(childName)

	local function OnInstanceSet()
		local instance = self.Instance
		if typeof(instance) == "Instance" then
			self._shown:Fire(instance, self._shownJanitor)
			self._shownJanitor:Add(instance:GetPropertyChangedSignal("Parent"):Connect(function()
				if not instance.Parent then
					self._shownJanitor:Clean()
				end
			end))
			self._shownJanitor:Add(function()
				if self.Instance == instance then
					self.Instance = nil
				end
			end)
		end
	end

	local function OnChildAdded(child: Instance)
		if child.Name == childName and not self.Instance then
			self.Instance = child
			OnInstanceSet()
		end
	end

	self._janitor:Add(parent.ChildAdded:Connect(OnChildAdded))
	if self.Instance then
		OnInstanceSet()
	end

	return self

end


function Streamable:Observe(handler)
	if self.Instance then
		task.spawn(handler, self.Instance, self._shownJanitor)
	end
	return self._shown:Connect(handler)
end


function Streamable:Destroy()
	self._janitor:Destroy()
end


export type Streamable = typeof(Streamable.new(workspace, "X"))


return Streamable
-- Make the object appear when the ProximityPrompt is used


local function effect()
	if object then
		Prox.Enabled = true
		script.Parent.Transparency = 0
		object.Transparency = 1
		game.Workspace.Light.SpotLight.Enabled = false
	end
end

local function onPromptTriggered()
	if object then
		Prox.Enabled = false
		game.Workspace.swewe:Destroy()
		object.Transparency = 0
		script.Parent.Transparency = 1
		script.Parent.Parent.clockactivate.Transparency = 0
		game.Workspace.Light.SpotLight.Enabled = true
		game.Workspace.serp.ind1.Script.Enabled = true
		game.Workspace.serp.ind2.Script.Disabled = false
		game.Workspace.Door:Destroy()
		game.Workspace.Dummy:Destroy()
		script.Parent.Parent.objective.BillboardGui.ImageLabel.Visible = false
		game.Workspace.Phone.Phone.BillboardGui.Enabled = true
		wait(120)
		effect()
	end
end
-- /**
--  * Class representing one diff tuple.
--  * Attempts to look like a two-element array (which is what this used to be).
--  * @param {number} op Operation, one of: DIFF_DELETE, DIFF_INSERT, DIFF_EQUAL.
--  * @param {string} text Text to be deleted, inserted, or retained.
--  * @constructor
--  */
-- ROBLOX FIXME Luau: Luau can't represent [1]: number, [2]: string


export type Diff = Array<any>
local Diff = {}
Diff.__index = Diff
function Diff.new(op: number, text: string): Diff
	return (setmetatable({ op :: any, text }, Diff) :: any) :: Diff
end
-- Represents a CastStateInfo :: https://etithespirit.github.io/FastCastAPIDocs/fastcast-objects/caststateinfo/


export type CastStateInfo = {
	UpdateConnection: RBXScriptSignal,
	HighFidelityBehavior: number,
	HighFidelitySegmentSize: number,
	Paused: boolean,
	TotalRuntime: number,
	DistanceCovered: number,
	IsActivelySimulatingPierce: boolean,
	IsActivelyResimulating: boolean,
	CancelHighResCast: boolean,
	Trajectories: {[number]: CastTrajectory}
}
---////==========================================\\\---	
--To install the product, group them together with the switch. You can have multiple products installed and be controlled by one switch!--
--Products include, but not limited to: some fans, lights, alarms, etc. 
---////==========================================\\\---	


IsOn = false
function onClicked()
	if IsOn == false then
	IsOn = true	
 	script.Parent.Parent.Switch2.Transparency = 1
	script.Parent.Parent.Switch1.Transparency = 0
	script.Parent.Parent.IsOn.Value = true	
	elseif IsOn == true then
	IsOn = false	
	script.Parent.Parent.Switch2.Transparency = 0
	script.Parent.Parent.Switch1.Transparency = 1
	script.Parent.Parent.IsOn.Value = false
	end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
--//Handling//--


SteeringAngle = 40 --{Steering angle in degrees}
SteerSpeed = 0.085 --{.02 being slow, 0.1 being almost instantly}
TiresFront = 2 --{1 = eco, 2 = road, 3 = sport}
TiresRear = 2 --{1 = eco, 2 = road, 3 = sport}
DownforceF = 0 --{[0-5] Provides downforce to the front at the cost of drag}
DownforceR = 0 --{[0-5] Provides downforce to the rear at the cost of drag}
BrakeBias = 72 --{100 = all on front || 0 = all on rear}
BrakePower = 80  --{100 = strong brakes 0 = close to no brakes}
TC = false
ABS = true
--- Calls the transform function on this argument.
-- The return value(s) from this function are passed to all of the other argument methods.
-- Called automatically at instantiation


function Argument:Transform()
	if #self.TransformedValues ~= 0 then
		return
	end

	local rawValue = self.RawValue
	if self.Type.ArgumentOperatorAliases then
		rawValue = self.Type.ArgumentOperatorAliases[rawValue] or rawValue
	end

	if rawValue == "." and self.Type.Default then
		rawValue = self.Type.Default(self.Executor) or ""
		self.RawSegmentsAreAutocomplete = true
	end

	if rawValue == "?" and self.Type.Autocomplete then
		local strings, options = self:GetDefaultAutocomplete()

		if not options.IsPartial and #strings > 0 then
			rawValue = strings[math.random(1, #strings)]
			self.RawSegmentsAreAutocomplete = true
		end

	end

	if self.Type.Listable and #self.RawValue > 0 then
		local randomMatch = rawValue:match("^%?(%d+)$")
		if randomMatch then
			local maxSize = tonumber(randomMatch)

			if maxSize and maxSize > 0 then
				local items = {}
				local remainingItems, options = self:GetDefaultAutocomplete()

				if not options.IsPartial and #remainingItems > 0 then
					for _ = 1, math.min(maxSize, #remainingItems) do
						table.insert(items, table.remove(remainingItems, math.random(1, #remainingItems)))
					end

					rawValue = table.concat(items, ",")
					self.RawSegmentsAreAutocomplete = true
				end
			end
		elseif rawValue == "*" or rawValue == "**" then
			local strings, options = self:GetDefaultAutocomplete()

			if not options.IsPartial and #strings > 0 then
				if rawValue == "**" and self.Type.Default then
					local defaultString = self.Type.Default(self.Executor) or ""

					for i, string in ipairs(strings) do
						if string == defaultString then
							table.remove(strings, i)
						end
					end
				end

				rawValue = table.concat(
					strings,
					","
				)
				self.RawSegmentsAreAutocomplete = true
			end
		end

		rawValue = unescapeOperators(rawValue)

		local rawSegments = Util.SplitStringSimple(rawValue, ",")

		if #rawSegments == 0 then
			rawSegments = {""}
		end

		if rawValue:sub(#rawValue, #rawValue) == "," then
			rawSegments[#rawSegments + 1] = "" -- makes auto complete tick over right after pressing ,
		end

		for i, rawSegment in ipairs(rawSegments) do
			self.RawSegments[i] = rawSegment
			self.TransformedValues[i] = { self:TransformSegment(rawSegment) }
		end

		self.TextSegmentInProgress = rawSegments[#rawSegments]
	else
		rawValue = unescapeOperators(rawValue)

		self.RawSegments[1] = unescapeOperators(rawValue)
		self.TransformedValues[1] = { self:TransformSegment(rawValue) }
		self.TextSegmentInProgress = self.RawValue
	end
end

function Argument:TransformSegment(rawSegment)
	if self.Type.Transform then
		return self.Type.Transform(rawSegment, self.Executor)
	else
		return rawSegment
	end
end
--		print(animName .. " * " .. idx .. " [" .. origRoll .. "]")


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

		if (toolAnimInstance ~= anim) then
			
			if (toolAnimTrack ~= nil) then
				toolAnimTrack:Stop()
				toolAnimTrack:Destroy()
				transitionTime = 0
			end
					
			-- load it to the humanoid; get AnimationTrack
			toolAnimTrack = humanoid:LoadAnimation(anim)
			if priority then
				toolAnimTrack.Priority = priority
			end
			 
			-- play the animation
			toolAnimTrack:Play(transitionTime)
			toolAnimName = animName
			toolAnimInstance = anim

			currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:Connect(toolKeyFrameReachedFunc)
		end
end

function stopToolAnimations()
	local oldAnim = toolAnimName

	if (currentToolAnimKeyframeHandler ~= nil) then
		currentToolAnimKeyframeHandler:Disconnect()
	end

	toolAnimName = ""
	toolAnimInstance = nil
	if (toolAnimTrack ~= nil) then
		toolAnimTrack:Stop()
		toolAnimTrack:Destroy()
		toolAnimTrack = nil
	end


	return oldAnim
end
--[[
	Returns the number of itemIds in the local user's inventory
--]]



local ReplicatedStorage = game:GetService("ReplicatedStorage")

local PlayerDataClient = require(ReplicatedStorage.Source.PlayerData.Client)
local PlayerDataKey = require(ReplicatedStorage.Source.SharedConstants.PlayerDataKey)
local getCategoryForItemId = require(ReplicatedStorage.Source.Utility.Farm.getCategoryForItemId)

local function getItemAmountInInventory(itemId: string): number
	local categoryId = getCategoryForItemId(itemId)

	local inventory = PlayerDataClient.get(PlayerDataKey.Inventory)
	local categoryItemCount = inventory[categoryId] or {}
	local itemCount = categoryItemCount[itemId] or 0

	return itemCount
end

return getItemAmountInInventory
--// All global vars will be wiped/replaced except script



return function(data)
	local playergui = service.PlayerGui
	local localplayer = service.Players.LocalPlayer
	local scr = client.UI.Prepare(script.Parent.Parent)
	local main = scr.Main
	local t1 = main.Title
	local t2 = main.Message
	local msg = data.Message
	local color = data.Color

	local found = client.UI.Get("Output")
	if found then
		for i,v in pairs(found) do
			local p = v.Object
			if p and p.Parent then
				p.Main.Position = UDim2.new(0, 0, 0.35, p.Main.Position.Y.Offset+50)
			end
		end
	end

	t2.Text = msg
	
	spawn(function()
		local sound = Instance.new("Sound",service.LocalContainer())
		sound.SoundId = "rbxassetid://7152562261"
		sound.Volume = 0.1
		sound:Play()
		wait(0.8)
		sound:Destroy()
	end)

	main.Size = UDim2.new(1, 0, 0, 0)
	gTable.Ready()
	main:TweenSize(UDim2.new(1, 0, 0, 50), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.1)
	wait(5)
	gTable.Destroy()
end
--[[
	Randomly picks a tool type depending on weight, and spawns it in specified position.
]]


local function createRandomToolAtPosition(position)
	local randomPick = random:NextInteger(1, 100)

	local tool
	if randomPick > 92 then
		tool = torch:Clone()
	elseif randomPick > 80 then
		tool = gravityFuel:Clone()
	elseif randomPick > 10 then
		tool = repairKit:Clone()
	elseif randomPick > 5 then
		tool = smallCargo:Clone()
	elseif randomPick > 3 then
		tool = largeCargo:Clone()
	else
		tool = broom:Clone()
	end

	tool.Position = position

	tool.Parent = workspace.Tools

	tool:SetNetworkOwner(nil)
end

return function()
	local rooms = RoomManager.getRooms()

	for _, room in pairs(rooms) do
		local regions = room:getRegions()
		local toolsToSpawnPerRegion = TOTAL_TOOLS_PER_ROOM / #regions

		for _, region in pairs(regions) do
			for i = 1, toolsToSpawnPerRegion do
				local position = getRandomClearLocationInRegionAsync(region, AREA_CLEAR_SIZE)

				createRandomToolAtPosition(position)
			end
		end
	end
end