Pinkstack/roblox-luau-corpus-text huggingface dataset:
-- Public Constructors



function RotatedRegion3.new(cframe, size)
	local self = setmetatable({}, RotatedRegion3)
	local set = Vertices.Block(cframe, size/2)
	
	self.CFrame = cframe
	self.Size = size
	self.Shape = "Block"
	
	self.Set = set
	self.Support = Supports.PointCloud
	self.Centroid = cframe.p
	
	self.AlignedRegion3 = Region3.new(worldBoundingBox(set))

	return self
end

RotatedRegion3.Block = RotatedRegion3.new

function RotatedRegion3.Wedge(cframe, size)
	local self = setmetatable({}, RotatedRegion3)
	local set = Vertices.Block(cframe, size/2)
	
	self.CFrame = cframe
	self.Size = size
	self.Shape = "Wedge"
	
	self.Set = Vertices.Wedge(cframe, size/2)
	self.Support = Supports.PointCloud
	self.Centroid = Vertices.GetCentroid(self.Set)
	
	self.AlignedRegion3 = Region3.new(worldBoundingBox(set))

	return self
end

function RotatedRegion3.CornerWedge(cframe, size)
	local self = setmetatable({}, RotatedRegion3)
	local set = Vertices.Block(cframe, size/2)
	
	self.CFrame = cframe
	self.Size = size
	self.Shape = "CornerWedge"
	
	self.Set = Vertices.CornerWedge(cframe, size/2)
	self.Support = Supports.PointCloud
	self.Centroid = Vertices.GetCentroid(self.Set)
	
	self.AlignedRegion3 = Region3.new(worldBoundingBox(set))

	return self
end

function RotatedRegion3.Cylinder(cframe, size)
	local self = setmetatable({}, RotatedRegion3)
	local set = Vertices.Block(cframe, size/2)
	
	self.CFrame = cframe
	self.Size = size
	self.Shape = "Cylinder"
	
	self.Set = {cframe, size/2}
	self.Support = Supports.Cylinder
	self.Centroid = cframe.p
	
	self.AlignedRegion3 = Region3.new(worldBoundingBox(set))

	return self
end

function RotatedRegion3.Ball(cframe, size)
	local self = setmetatable({}, RotatedRegion3)
	local set = Vertices.Block(cframe, size/2)
	
	self.CFrame = cframe
	self.Size = size
	self.Shape = "Ball"
	
	self.Set = {cframe, size/2}
	self.Support = Supports.Ellipsoid
	self.Centroid = cframe.p
	
	self.AlignedRegion3 = Region3.new(worldBoundingBox(set))

	return self
end

function RotatedRegion3.FromPart(part)
	return RotatedRegion3[Vertices.Classify(part)](part.CFrame, part.Size)
end
--[[if script.Parent.Parent.Values.Win.Value == true then
script.Parent.Parent.Sound.Win:Play()
script.Parent.Parent.Sound.Idle:Stop()
script.Parent.Parent.WINNER.Disabled = false
end]]


script.Parent.Parent.Configuration.GameOn.Value = false
script.Parent.Parent.MainScript.Disabled = false
script.Disabled = true
end
script.Parent.Parent.Sensortwo.Touched:Connect(onTouched)
--// bolekinds



local Time = game:GetService("Lighting")
local Bandit = game.ServerStorage.Bandit
local BanditSpawns = workspace.BanditSpawns
local con
local mailboxcon

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
	if game.Lighting.ClockTime == 7 then
		local randomNum = math.random(1, 10)
		local banditRaid = false
		if randomNum >= 5 then
			banditRaid = true
		end
		game.ServerStorage.ServerData.Age.Value += 1
		game.ServerStorage.ServerData.Day.Value += 1
		if mailboxcon then
			mailboxcon:Disconnect()
		end
		if game.ServerStorage.ServerData.Day.Value >= 5 then
			if game.ServerStorage.ServerData.HasKeys.Value == false then
				workspace.Door.Knock:Play()
				workspace.Door.Sparkles.Enabled = true
				workspace.Door.ProximityPrompt.Enabled = true
				con = workspace.Door.ProximityPrompt.Triggered:Connect(function(plr)
					game.ServerStorage.key:Clone().Parent = plr.PlayerGui
					workspace.Door.Knock:Stop()
					workspace.Door.Sparkles.Enabled = false
					workspace.Door.ProximityPrompt.Enabled = false
					con:Disconnect()
				end)
			end
		end
		if game.ServerStorage.ServerData.HasKeys.Value == true then
			if banditRaid == true then
				workspace.Sound3:Play()
				game.ReplicatedStorage.Bandit:FireAllClients()
				repeat
					task.wait(2.5) 
					local bandit = game.ServerStorage.Bandit:Clone()
					bandit.HumanoidRootPart.CFrame = BanditSpawns:GetChildren()[math.random(1, #BanditSpawns:GetChildren())].CFrame + Vector3.new(0,10,0)
					bandit.Parent = workspace.AttackableNPCS
				until workspace.Sound3.Playing == false
				for i, v in ipairs(workspace.AttackableNPCS:GetChildren()) do
					v:Destroy()
				end
				for i, v in ipairs(workspace.FloppaBlocker.bandits:GetChildren()) do
					v:Destroy()
				end
				game.ReplicatedStorage.Bandit2:FireAllClients()
				workspace.Sound3:Stop()
				workspace.Sound:Play()
			end
			workspace.Mailbox.Main.Sparkles.Enabled = true
			workspace.Mailbox.Main.ProximityPrompt.Enabled = true
			mailboxcon = workspace.Mailbox.Main.ProximityPrompt.Triggered:Connect(function(plr)
				workspace.Mailbox.Main.Sparkles.Enabled = false
				workspace.Mailbox.Main.ProximityPrompt.Enabled = false
				local c = game.ServerStorage.mailboxthings:GetChildren()[math.random(1,#game.ServerStorage.mailboxthings:GetChildren())]:Clone()
				c.Parent = plr.PlayerGui
				mailboxcon:Disconnect()
				mailboxcon = nil
			end)
		end
		game.ServerStorage.TempData.CanGiveRent.Value = true
		workspace.Roommate.Head.Dialog["Gimme rent"].ResponseDialog = "Alright"
	end
end)

while true do
	task.wait(0.05)
	Time:SetMinutesAfterMidnight(Time:GetMinutesAfterMidnight()+0.5)
end
--



function Raycast.FindPartOnRayWithCallbackWithIgnoreList(ray, list, terrainCellsAreCubes, ignoreWater, loopout, callbackFunc)
	local maxDistance = ray.Direction.Magnitude
	local direction = ray.Direction.Unit
	
	loopout = loopout or 25
	local loopCount = 0
	
	local lastPosition = ray.Origin
	local distance = 0
	
	local hit, position, normal, material
	
	repeat
		local r = Ray.new(lastPosition, direction * (maxDistance - distance))
		hit, position, normal, material = WORKSPACE:FindPartOnRayWithIgnoreList(ray, list, terrainCellsAreCubes, ignoreWater, true)
		local result = callbackFunc(hit, position, normal, material)
		
		if (result == CALLBACKRESULT.Continue) then
			distance = (ray.Origin - position).Magnitude
			lastPosition = position
		elseif (result == CALLBACKRESULT.Finished) then
			return hit, position, normal, material
		elseif (result == CALLBACKRESULT.Fail or result == nil) then
			break
		end
		
		loopCount = loopCount + 1
	until (loopCount > loopout or distance >= maxDistance - 0.1)
	
	return
end

function Raycast.FindPartOnRayWithCallbackWithWhiteList(ray, list, terrainCellsAreCubes, ignoreWater, callbackFunc)
	local maxDistance = ray.Direction.Magnitude
	local direction = ray.Direction.Unit
	
	local lastPosition = ray.Origin
	local distance = 0
	
	local hit, position, normal, material
	
	repeat
		local r = Ray.new(lastPosition, direction * (maxDistance - distance))
		hit, position, normal, material = WORKSPACE:FindPartOnRayWithWhiteList(ray, list, terrainCellsAreCubes, ignoreWater, true)
		local result = callbackFunc(hit, position, normal, material)
		
		if (result == CALLBACKRESULT.Continue) then
			distance = (ray.Origin - position).Magnitude
			lastPosition = position
		elseif (result == CALLBACKRESULT.Finished) then
			return hit, position, normal, material
		elseif (result == CALLBACKRESULT.Fail or result == nil) then
			break
		end
	until (distance >= maxDistance - 0.1)
	
	return
end

function Raycast.FindPartOnRayWithCallback(ray, ignore, terrainCellsAreCubes, ignoreWater, callbackFunc)
	return Raycast.FindPartOnRayWithCallbackWithIgnoreList(ray, {ignore}, terrainCellsAreCubes, ignoreWater, callbackFunc)
end
--[[
	Sets the velocity of the internal springs, overwriting the existing velocity
	of this Spring. This doesn't affect position.

	If the type doesn't match the current type of the spring, an error will be
	thrown.
]]


function class:setVelocity(newValue: PubTypes.Animatable)
	local newType = typeof(newValue)
	if newType ~= self._currentType then
		logError("springTypeMismatch", nil, newType, self._currentType)
	end

	self._springVelocities = unpackType(newValue, newType)
	SpringScheduler.add(self)
end
-- Public Functions




function CubicSpline:AtTime(t)
	local n = #self.Points
	local ct = math.clamp(t, 0, n)
	local floor = math.floor(ct)
	local ft = ct - floor
	
	local spline = (floor % (n - 1)) + 1
	local a, b, c, d = unpack(self.Coefficients)

	return a[spline] + b[spline]*ft + c[spline]*ft*ft + d[spline]*ft*ft*ft
end

function CubicSpline:AtPercentage(p)
	local t = p * self.TotalLength
	local lengths = self.Lengths
	
	if (p >= 1) then
		return self.Points[#self.Points]
	end
	
	local spline = 1
	while (t > lengths[spline]) do
		t = t - lengths[spline]
		spline = spline + 1
	end

	local s = t / lengths[spline]
	
	for i = 1, NEWTON_N do
		s = s - (integrate(self, spline, s) - t) / arcLengthIntegrand(self, spline, s)
	end
	
	return self:AtTime((spline - 1) + s)
end
--[[ Initialization/Setup ]]

--
local function createTouchGuiContainer()
	if TouchGui then TouchGui:Destroy() end
	
	-- Container for all touch device guis
	TouchGui = Instance.new('ScreenGui')
	TouchGui.Name = "TouchGui"
	TouchGui.Parent = PlayerGui
	
	TouchControlFrame = Instance.new('Frame')
	TouchControlFrame.Name = "TouchControlFrame"
	TouchControlFrame.Size = UDim2.new(1, 0, 1, 0)
	TouchControlFrame.BackgroundTransparency = 1
	TouchControlFrame.Parent = TouchGui
end
-- A simple function to explode a specified part


function Explode(part)
	local explosion = Instance.new("Explosion", workspace)
	explosion.ExplosionType = Enum.ExplosionType.NoCraters
	explosion.Position = part.Position
	explosion.BlastRadius = config.ExplosionRadius.Value
	part:Destroy()
script.Parent:remove()
end

script.Parent.Throw.OnServerEvent:connect(function(player, mousePosition)
	local handlePos = Vector3.new(tool.Handle.Position.X, 0, tool.Handle.Position.Z) -- remove Y from the equation, it's not needed
	local mousePos = Vector3.new(mousePosition.X, 0, mousePosition.Z) -- ditto
	local distance = (handlePos - mousePos).magnitude -- Get the distance between the handle and the mouse
	local altitude = mousePosition.Y - tool.Handle.Position.Y
	local angle = AngleOfReach(distance, altitude, config.GrenadeVelocity.Value) -- Calculate the angle
	
	tool.Handle.Transparency = 1
	local grenade = tool.Handle:Clone()
	grenade.Parent = workspace
	grenade.Transparency = 1
	grenade.CanCollide = true
	grenade.CFrame = tool.Handle.CFrame
	grenade.Velocity = (CFrame.new(grenade.Position, Vector3.new(mousePosition.X, grenade.Position.Y, mousePosition.Z)) * CFrame.Angles(angle, 0, 0)).lookVector * config.GrenadeVelocity.Value -- Throwing 'n stuff, it probably didn't need to be this long
	spawn(function()
	if config.ExplodeOnTouch.Value then
		grenade.Touched:connect(function(hit)
			if hit.Parent ~= tool.Parent and hit.CanCollide then -- Make sure what we're hitting is collidable
				Explode(grenade)
			end
		end)
	else
		
			wait(config.FuseTime.Value)
			Explode(grenade)
	end
	end)
	wait(config.Cooldown.Value)
	tool.Handle.Transparency = 1
end)
--[[
	Races a set of Promises and returns the first one that resolves,
	cancelling the others.
]]


function Promise.race(promises)
	assert(type(promises) == "table", string.format(ERROR_NON_LIST, "Promise.race"))

	for i, promise in pairs(promises) do
		assert(Promise.is(promise), string.format(ERROR_NON_PROMISE_IN_LIST, "Promise.race", tostring(i)))
	end

	return Promise._new(debug.traceback(nil, 2), function(resolve, reject, onCancel)
		local newPromises = {}
		local finished = false

		local function cancel()
			for _, promise in ipairs(newPromises) do
				promise:cancel()
			end
		end

		local function finalize(callback)
			return function (...)
				cancel()
				finished = true
				return callback(...)
			end
		end

		if onCancel(finalize(reject)) then
			return
		end

		for i, promise in ipairs(promises) do
			newPromises[i] = promise:andThen(finalize(resolve), finalize(reject))
		end

		if finished then
			cancel()
		end
	end)
end
--[[Front]]

--
Tune.FTireProfile	= 2		-- Tire profile, aggressive or smooth
Tune.FProfileHeight	= .4		-- Profile height, conforming to tire

Tune.FTireCompound	= 1			-- The more compounds you have, the harder your tire will get towards the middle, sacrificing grip for wear
Tune.FTireFriction	= 1		-- Your tire's friction in the best conditions.
--[[Engine]]


	--Torque Curve
	Tune.Horsepower		= 350	--	[TORQUE CURVE VISUAL]
	Tune.IdleRPM		= 700		--		https://www.desmos.com/calculator/2uo3hqwdhf
	Tune.PeakRPM		= 9000		--		Use sliders to manipulate values
	Tune.Redline		= 11000
	Tune.EqPoint		= 5000
	Tune.PeakSharpness	= 7.5
	Tune.CurveMult		= 0.16
	
	--Incline Compensation
	Tune.InclineComp	= 1.7			-- Torque compensation multiplier for inclines (applies gradient from 0-90 degrees)
	
	--Misc
	Tune.RevAccel		= 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)
--[=[
	@within TableUtil
	@function Lock
	@param tbl table
	@return table

	Locks the table using `table.freeze`, as well as any
	nested tables within the given table. This will lock
	the whole deep structure of the table, disallowing any
	further modifications.

	```lua
	local tbl = {xyz = {abc = 32}}
	tbl.xyz.abc = 28 -- Works fine
	TableUtil.Lock(tbl)
	tbl.xyz.abc = 64 -- Will throw an error (cannot modify readonly table)
	```
]=]


local function Lock<T>(tbl: T): T
	local function Freeze(t: { [any]: any })
		for k, v in pairs(t) do
			if type(v) == "table" then
				t[k] = Freeze(v)
			end
		end
		return table.freeze(t)
	end
	return Freeze(tbl :: any)
end
-- Local Functions


local function awardBadge(player, badgeId)
	-- Fetch badge information
	local success, badgeInfo = pcall(function()
		return BadgeService:GetBadgeInfoAsync(badgeId)
	end)
	if success then
		-- Confirm that badge can be awarded
		if badgeInfo.IsEnabled then
			-- Award badge
			local awarded, errorMessage = pcall(function()
				BadgeService:AwardBadge(player.UserId, badgeId)
				return true
			end)
			if not awarded then
				warn("Error while awarding badge:", errorMessage)
				return false
			end
		end
	else
		warn("Error while fetching badge info!")
		return false
	end
end

local function handleCodeRedemption(player, code)
	-- Check if code is valid
	local foundIndex = false
	for codeIndex, badgeId in ipairs (GameSettings.codes) do
		if codeIndex == code then
			foundIndex = codeIndex
		end
	end
	
	if not foundIndex then
		RedeemCode:FireClient(player, "Invalid code!")
		return 
	end

	-- Player has redeemed code, can't redeem again
	if DataStore:HasRedeemedCode(player, code) then
		RedeemCode:FireClient(player, "Code already redeemed!")
		return 
	end
	
	local redeemed = DataStore:RedeemCode(player, GameSettings.codes[foundIndex])
	if redeemed then
		-- Give prize based on code
		if awardBadge(player, GameSettings.codes[foundIndex]) then
			-- Tell client that code has been redeemed
			RedeemCode:FireClient(player, "Successfully redeemed!")
		end
	end
	
	-- Tell client that code has been redeemed
	RedeemCode:FireClient(player, "Error redeeming code!")
end
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------



local toolAnimName = ""
local toolAnimTrack = nil
local toolAnimInstance = nil
local currentToolAnimKeyframeHandler = nil

function toolKeyFrameReachedFunc(frameName)
	if (frameName == "End") then
		playToolAnimation(toolAnimName, 0.0, Humanoid)
	end
end


function playToolAnimation(animName, transitionTime, humanoid, priority)
		local idx = rollAnimation(animName)
		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
-- Requests the mob to perform a jump if there's an obstacle in the way of it.


function AI:RequestJump(Mob)
	if not Mob.Instance then
		return
	end
	
	local Root: BasePart = Mob.Root
	local JumpHeight: number = (Mob.Enemy.JumpPower ^ 2) / (2 * workspace.Gravity) * .8
	local HipPoint: CFrame = Root.CFrame + (Root.CFrame.LookVector*(Root.Size.Z/2-0.2)) + (Root.CFrame.UpVector/-Root.Size.Y/2)
	
	local RaycastResult = workspace:Raycast(
		HipPoint.Position,
		HipPoint.LookVector * Mob.Enemy.WalkSpeed/4,
		RaycastParams
	)
	
	if RaycastResult then
		-- There is an obstacle, but they should be able to jump over it!
		if RaycastResult.Instance ~= workspace.Terrain then
			local PartHeight: number = (RaycastResult.Instance.Position + Vector3.new(0, RaycastResult.Instance.Size.Y/2, 0)).Y
			if (HipPoint.Position.Y + JumpHeight) > PartHeight then
				Mob.Enemy.Jump = true
			end
		else
			Mob.Enemy.Jump = true
		end
	end
end
-- Place in StarterGui.



local Players = game:GetService("Players")
 
function onPlayerAdded(player)
	game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
	Text = ("[SERVER]: ".. player.Name .. " has entered the game.");
	Color = Color3.new(255,255,255);
	Font = Enum.Font.SourceSansBold; 
	FontSize = Enum.FontSize.Size18;
})
end
 
Players.PlayerAdded:connect(onPlayerAdded)
 
for _,player in pairs(Players:GetPlayers()) do
     onPlayerAdded(player)
end
--!strict
--[=[
	@function flatten
	@within Array

	@param array {T} -- The array to flatten.
	@param depth? number -- The depth to flatten the array to.
	@return {T} -- The flattened array.

	Flattens an array. If depth is not specified, it will flatten
	the array as far as it can go.

	```lua
	local array = {
		{ 1, 2, 3 },
		{ 4, 5, 6 },
		{ 7, { 8, 9 } },
	}

	local new = Flatten(array) -- { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
	local new = Flatten(array, 1) -- { 1, 2, 3, 4, 5, 6, 7, { 8, 9 } }
	```
]=]


local function flatten<T>(array: { T }, depth: number?): { T }
	depth = if type(depth) == "number" then depth else math.huge

	local result = {}

	for _, value in ipairs(array) do
		if type(value) == "table" and depth > 0 then
			local nested = flatten(value, depth - 1)

			for _, nestedValue in ipairs(nested) do
				table.insert(result, nestedValue)
			end
		else
			table.insert(result, value)
		end
	end

	return result
end

return flatten
-- Local Functions


local function OnPlayerAdded(player)
	-- Setup leaderboard stats
	local leaderstats = Instance.new("Model", player)
	leaderstats.Name = "leaderstats"
	
	local KWA = Instance.new("StringValue", leaderstats)
	if Configurations.GRANT_ASSISTS then
		KWA.Name = "KO - WO - A"
		KWA.Value = "0 - 0 - 0"
	else
		KWA.Name = "KO - WO"
		KWA.Value = "0 - 0"
	end
	
	ScoreArray[player] = { 0, 0, 0 } -- KOs, WOs, Assists
	
	TeamManager:AssignPlayerToTeam(player)
	
	player.CharacterAdded:connect(function(character)
		character:WaitForChild("Humanoid").Died:connect(function()
			PlayerManager:PlayerDied(player)
			wait(Configurations.RESPAWN_TIME)
			if GameRunning then
				player:LoadCharacter()
			end
		end)
	end)
	
	if PlayersCanSpawn then
		player:LoadCharacter()
	else
		DisplayManager:StartIntermission(player)
	end
end

local function OnPlayerRemoving(player)
	TeamManager:RemovePlayer(player)
end

local function UpdatePlayerScore(player)
	local KOString = tostring(ScoreArray[player][1])
	local WOString = tostring(ScoreArray[player][2])
	local AssistString = tostring(ScoreArray[player][3])
	
	if not Configurations.GRANT_ASSISTS then
		if KOString:len() < WOString:len() then
			while KOString:len() < WOString:len() do
				KOString = " " .. KOString
			end
		else
			while WOString:len() < WOString:len() do
				WOString = WOString .. " "
			end
		end
		player.leaderstats["KO - WO"].Value = KOString .. " - " .. WOString
	else
		player.leaderstats["KO - WO - A"].Value = KOString .. " - " .. WOString .. " - " .. AssistString
	end
end
--[[
	Sets the given emote as unlocked for the given Player.
]]


local function unlockEmote(runService, emoteManager, changeEmoteLock)
	if runService:IsServer() then
		return function(player: Player, emoteName: string): nil
			assert(t.string(emoteName))
			emoteManager:setEmoteIsLockedForPlayer(player, emoteName, false)
		end
	else
		-- Calling unlockEmote from the client is deprecated. To preserve
		-- backwards compatibility, a remote event is fired to the new server
		-- side unlockEmote function
		return function(emoteName: string): nil
			warn("Calling unlockEmote from the client is deprecated. Please call from a server Script instead.")
			changeEmoteLock:FireServer(emoteName, false)
		end
	end
end

return unlockEmote
--[[
	Sets up the EmoteManager for the given player.
]]


local function setupEmoteManager(player)
	local humanoid = player.Character:WaitForChild("Humanoid")
	local humanoidDescription = humanoid:WaitForChild("HumanoidDescription")
	emoteManager:setup(player, humanoidDescription)

	local connection
	connection = humanoid.Died:Connect(function()
		stopEmote(player)
		player.CharacterAdded:Wait()
		setupEmoteManager(player)
		connection:Disconnect()
	end)
end

local function onPlayerAdded(player)
	if not player.Character then
		player.CharacterAdded:Wait()
	end
	setupEmoteManager(player)
end

local function onPlayerRemoving(player)
	stopEmote(player)

	emoteManager:cleanup(player.UserId)
end

local function onChangeEmoteLock(player, emoteName, isLocked)
	assert(onChangeEmoteLockCheck(emoteName, isLocked))

	emoteManager:setEmoteIsLockedForPlayer(player, emoteName, isLocked)
end

emotePlayed.OnServerEvent:Connect(startEmote)
emoteStopped.OnServerEvent:Connect(stopEmote)
changeEmoteLock.OnServerEvent:Connect(onChangeEmoteLock)

Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(onPlayerRemoving)

loadEmoteAssets()
-- Ensures that 'actual' & 'expected' are of type 'number'


local function ensureNumbers(actual: any, expected: any, matcherName: string, options: MatcherHintOptions?): ()
	ensureActualIsNumber(actual, matcherName, options)
	ensureExpectedIsNumber(expected, matcherName, options)
end

local function ensureExpectedIsNonNegativeInteger(expected: any, matcherName: string, options: MatcherHintOptions?): ()
	if typeof(expected) ~= "number" or not Number.isSafeInteger(expected) or expected < 0 then
		local matcherString = matcherName

		if not options then
			matcherString = "[.never]" .. matcherString
		end

		error(
			Error(
				matcherErrorMessage(
					matcherHint(matcherString, nil, nil, options),
					EXPECTED_COLOR("expected") .. " value must be a non-negative integer",
					printWithType("Expected", expected, printExpected)
				)
			)
		)
	end
end
--This script should work. Only 30 lines. Amazing! Feel free to add more buttons in tab to your liking.



local tabs = script.Parent.TABS:GetChildren()
for i = 1, #tabs do
	local buttons = tabs[i]:GetChildren()
	for i = 1, #buttons do
		function sell()
			hint = Instance.new("Hint",script.Parent.Parent.Parent.Parent.PlayerGui)
			Game:GetService("Debris"):AddItem(hint, 2)
			local gp = script.Parent.Parent.Parent.Parent.leaderstats:FindFirstChild("Gold")
			local bp = script.Parent.Parent.Parent.Parent.Backpack
			local sg = script.Parent.Parent.Parent.Parent.StarterGear
			local bptool = bp:FindFirstChild(buttons[i].Item.Value)
			local sgtool = sg:FindFirstChild(buttons[i].Item.Value)
			local sellvalue = buttons[i].SellPrice.Value
			if bptool ~= nil and sgtool ~= nil then
				bptool:Remove()
				sgtool:Remove()
				gp.Value = gp.Value + sellvalue
				hint.Text = "You sold " ..buttons[i].Text.. " for " ..buttons[i].PriceDisplay.Text.. " Gold!"
			elseif bptool == nil and sgtool ~= nil then
				sgtool:Remove()
				gp.Value = gp.Value + sellvalue
				hint.Text = "You sold " ..buttons[i].Text.. " for " ..buttons[i].PriceDisplay.Text.. " Gold!"
			else hint.Text = "You don't have " ..buttons[i].Text.. "!"
			end
		end
	buttons[i].MouseButton1Click:connect(sell)
	end
end