Roblox/luau_corpus huggingface dataset:
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
-- STATE CHANGE HANDLERS

function onRunning(speed)
	checkingSPEED(speed)
	local speedThreshold = 0.5
	if speed > speedThreshold then
		local scale = 16.0
		playAnimation("walk", 0.2, Humanoid)
		setAnimationSpeed(speed / scale)
		pose = "Running"
	else
		if emoteNames[currentAnim] == nil and not currentlyPlayingEmote then
			playAnimation("idle", 0.2, Humanoid)
			pose = "Standing"
		end
	end
end

function onDied()
	pose = "Dead"
end

function onJumping()
	playAnimation("jump", 0.1, Humanoid)
	jumpAnimTime = jumpAnimDuration
	pose = "Jumping"
end

function onClimbing(speed)
	local scale = 5.0
	playAnimation("climb", 0.1, Humanoid)
	setAnimationSpeed(speed / scale)
	pose = "Climbing"
end

function onGettingUp()
	pose = "GettingUp"
end

function onFreeFall()
	if (jumpAnimTime <= 0) then
		playAnimation("fall", fallTransitionTime, Humanoid)
	end
	pose = "FreeFall"
end

function onFallingDown()
	pose = "FallingDown"
end

function onSeated()
	pose = "Seated"
end

function onPlatformStanding()
	pose = "PlatformStanding"
end
--[[]	if mobile_is == false then
		mobile_is = true
		mobile_button = script.Parent.ParryButton
		mobile_button.Parent = plr.PlayerGui.PunchGui
	end

	mobile_button.MouseButton1Click:Connect(function()
		humanoid = plr.Character.Humanoid
		if humanoid.Parent.Parry.Value == false then
			humanoid.Parent.Parry.Value = true
			oldspeed = humanoid.WalkSpeed
			humanoid.WalkSpeed = 4
			pstart = humanoid:LoadAnimation(animation.Parry.pstart)
			pstart:Play()
			ppidle = humanoid:LoadAnimation(animation.Parry.pidle)
			ppidle:Play()
		else
			humanoid.Parent.Parry.Value = false
			humanoid.WalkSpeed = oldspeed
			ppidle:Stop()
			pstart:Stop()
		end
	end)]]
end)


script.Parent.Unequipped:Connect(function()
	attach.Parent = script.Parent
	motor6d:Remove()
	idle:Stop()
	equip:Stop()
	if humanoid.Parent.Parry.Value == true then
		humanoid.Parent.Parry.Value = false
		humanoid.WalkSpeed = oldspeed
		ppidle:Stop()
		pstart:Stop()
	end
end)

local i = 1
local deb = false

script.Parent.Activated:Connect(function()
	if humanoid.Parent.Parry.Value == false then
	if deb == false then
		deb = true
		if i == 1 then
			p1 = humanoid:LoadAnimation(animation.Punches.p1)
			p1:Play()
			i = 2
				wait(.2)

			Hitbox:HitStart() 
			attach.swing:Play()
			attach.swing.PlaybackSpeed = .8
			p1.Stopped:Wait()
			Hitbox:HitStop() 
			deb = false
			attach.swing:Stop()
		elseif i == 2 then
			p2 = humanoid:LoadAnimation(animation.Punches.p2)
			p2:Play()
			i = 3
				wait(.2)

			Hitbox:HitStart() 
			attach.swing:Play()
			attach.swing.PlaybackSpeed = 1.1
			p2.Stopped:Wait()
			Hitbox:HitStop() 
			deb = false
			attach.swing:Stop()
		elseif i ==3  then
			p3 = humanoid:LoadAnimation(animation.Punches.p3)
			p3:Play()
			i = 4
				wait(.2)

			Hitbox:HitStart() 
			attach.swing:Play()
			attach.swing.PlaybackSpeed = 1
			p3.Stopped:Wait()

			Hitbox:HitStop() 
			deb = false
			attach.swing:Stop()
		elseif i ==4  then
			p4 = humanoid:LoadAnimation(animation.Punches.p4)
			p4:Play()
			oldspeed = script.Parent.Parent.Humanoid.WalkSpeed
			humanoid.WalkSpeed -= 10
			i = 1
				wait(.4)
				humanoid.AutoRotate = false
			Hitbox:HitStart() 
			attach.swing.PlaybackSpeed = .8
				attach.swing:Play()
				wait(.3)
				game.ReplicatedStorage.CamShakeEvent:FireClient(plr)
				attach.ground:Play()
			p4.Stopped:Wait()
			Hitbox:HitStop() 
			humanoid.WalkSpeed = oldspeed
			deb = false
			attach.swing:Stop()
			end
			humanoid.AutoRotate = true
		end
	end
end)

game.ReplicatedStorage.Parry.OnServerEvent:Connect(function(plr,parent)
	humanoid = plr.Character.Humanoid
	if parent == script.Parent then
		if humanoid.Parent.Parry.Value == false then
			humanoid.Parent.Parry.Value = true
			oldspeed = humanoid.WalkSpeed
			humanoid.WalkSpeed = 4
			pstart = humanoid:LoadAnimation(animation.Parry.pstart)
			pstart:Play()
			ppidle = humanoid:LoadAnimation(animation.Parry.pidle)
			ppidle:Play()
		else
			humanoid.WalkSpeed = oldspeed
			ppidle:Stop()
			pstart:Stop()
			wait(1)
			humanoid.Parent.Parry.Value = false
		end
	end
end)
-- Tweening size function
local tweenPartSize = function(part, duration, direction, size)
    
    local tween = tweenService:Create(part, TweenInfo.new(duration, Enum.EasingStyle.Sine, direction), {Size = size})
    tween:Play()

    return tween
end
-- Declarations
local Figure = script.Parent
local Head = Figure:WaitForChild("Head")
local Humanoid = Figure:WaitForChild("NPC")
local Regening = false
--// Walk and Sway
local L_139_

local L_140_ = 0.6
local L_141_ = 0.05 -- speed
local L_142_ = -0.1 -- height

local L_143_ = 0
local L_144_ = 0
local L_145_ = 35 --This is the limit of the mouse input for the sway
local L_146_ = -9 --This is the magnitude of the sway when you're unaimed
local L_147_ = -9 --This is the magnitude of the sway when you're aimed
---[[ Channel Settings ]]
module.GeneralChannelName = "All" -- You can set to nil to turn off echoing to a general channel.
module.ChannelsBarFullTabSize = 4 -- number of tabs in bar before it starts to scroll
module.MaxChannelNameLength = 12
--------- CONFIGURATION -----------
local detectionDistance = 40 -- slime will wander until a player comes within this distance
local wanderSpeed = 1 -- the walk speed at which the slime will wander as long as no player is within detection distance
local wanderDistance = 5 -- how far the slime can wander in any one direction at a time
local chaseSpeed = 5 -- the walk speed at which the slime will chase players
local damage = 5 -- how much damage will be done to a humanoid each time the slime touches one
local damageDebounceDelay = .5 -- how many seconds after dealing damage before damage can be dealt again
-- Messy code but it works.. (Alternative to playeradded since that doesn't work.) ((Also only fires once per second so no big deal))
spawn(function()
	while task.wait(1) do
		for _ , v in pairs(workspace:GetDescendants()) do
			if v:IsA("Sound") and v.Name == "Running" then
				v.Volume = 0
			end
		end
	end
end)
-- << Functions >> --

UserInputService.MouseIconEnabled = false

function lerp(a, b, c)
	return a + (b - a) * c
end

bobbing = game:GetService("RunService").RenderStepped:Connect(function(deltaTime)
	if script.Parent.Humanoid.MoveDirection.Magnitude > 0 then
		deltaTime = deltaTime * (script.Parent.Humanoid.WalkSpeed * 3.75)	
	else
		deltaTime = deltaTime * 60
	end
	
	if Humanoid.Health <= 0 then
		bobbing:Disconnect()
		return
	end
	local rootMagnitude = Humanoid.RootPart and Vector3.new(Humanoid.RootPart.Velocity.X, 0, Humanoid.RootPart.Velocity.Z).Magnitude or 0
	local calcRootMagnitude = math.min(rootMagnitude, 50)
	if deltaTime > 3 then
		func1 = 0
		func2 = 0
	else
		func1 = lerp(func1, math.cos(tick() * 0.5 * math.random(10, 15)) * (math.random(5, 20) / 200) * deltaTime, 0.05 * deltaTime)
		func2 = lerp(func2, math.cos(tick() * 0.5 * math.random(5, 10)) * (math.random(2, 10) / 200) * deltaTime, 0.05 * deltaTime)
	end
	Camera.CFrame = Camera.CFrame * (CFrame.fromEulerAnglesXYZ(0, 0, math.rad(func3)) * CFrame.fromEulerAnglesXYZ(math.rad(func4 * deltaTime), math.rad(val * deltaTime), val2) * CFrame.Angles(0, 0, math.rad(func4 * deltaTime * (calcRootMagnitude / 5))) * CFrame.fromEulerAnglesXYZ(math.rad(func1), math.rad(func2), math.rad(func2 * 10)))
	val2 = math.clamp(lerp(val2, -Camera.CFrame:VectorToObjectSpace((Humanoid.RootPart and Humanoid.RootPart.Velocity or Vector3.new()) / math.max(Humanoid.WalkSpeed, 0.01)).X * 0.08, 0.1 * deltaTime), -0.35, 0.2)
	func3 = lerp(func3, math.clamp(UserInputService:GetMouseDelta().X, -5, 5), 0.25 * deltaTime)
	func4 = lerp(func4, math.sin(tick() * int) / 5 * math.min(1, int2 / 10), 0.25 * deltaTime)
	if rootMagnitude > 1 then
		val = lerp(val, math.cos(tick() * 0.5 * math.floor(int)) * (int / 200), 0.25 * deltaTime)
	else
		val = lerp(val, 0, 0.05 * deltaTime)
	end
	if rootMagnitude > 12 then
		int = 20
		int2 = 18
	elseif rootMagnitude > 0.1 then
		int = 12
		int2 = 14
	else
		int2 = 0
	end
	vect3 = lerp(vect3, Camera.CFrame.LookVector, 0.125 * deltaTime)
end)
-- Changeable Settings
------------------------ 
local FlashlightKey = "F"

local brightness = 2

local range = 70

local shadowson = true
--Remember, this must be in StarterCharacterScripts
local trail = Instance.new("Trail")
local att0 = Instance.new("Attachment")
local att1 = Instance.new("Attachment")
-- Check if character is there
if script.Owner.Value.Character ~= nil then
	
	-- Find knife
	local knife = nil
	if script.Owner.Value.Backpack:FindFirstChild("Knife") then
		knife = script.Owner.Value.Backpack.Knife
	elseif script.Owner.Value.Character:FindFirstChild("Knife") then
		knife = script.Owner.Value.Character.Knife
	end
	if knife ~= nil then
		
		-- Make knife throw faster
		knife.KnifeScript.KnifeThrowSpeed.Value = knife.KnifeScript.KnifeThrowSpeed.Value * THROW_SPEED_CHANGE
		
	end
	
end
--[[
    Returns the object associated with the given key
]]
function Registry:get(key)
	return self.objects[key]
end
--[[ @brief Creates a new FunctionQueue object.
--]]
function FunctionQueue.new()
	local self = setmetatable({}, FunctionQueue.Meta);
	self._Functions = {};
	return self;
end

return FunctionQueue;
--[=[
	Connect a new handler to the event. Returns a connection object that can be disconnected.
	@param handler (... T) -> () -- Function handler called when `:Fire(...)` is called
	@return RBXScriptConnection
]=]
function Signal:Connect(handler)
	if not (type(handler) == "function") then
		error(("connect(%s)"):format(typeof(handler)), 2)
	end

	return self._bindableEvent.Event:Connect(function(key)
		-- note we could queue multiple events here, but we'll do this just as Roblox events expect
		-- to behave.

		local args = self._argMap[key]
		if args then
			handler(table.unpack(args, 1, args.n))
		else
			error("Missing arg data, probably due to reentrance.")
		end
	end)
end
-- Update the previous floor material, current floor material and sound data
humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()	
	getFloorMaterial()
	getSoundProperties()
	update()

	if humanoid.MoveDirection.Magnitude > 0 then 
		currentSound.Playing = true
	end
end)

updateWalkspeedRemote.OnServerEvent:Connect(function(player, walkspeed)
	player.Character.Humanoid.WalkSpeed = walkspeed
end)
--		child.C0 = CFrame.new(0,-0.6,0)*CFrame.fromEulerAnglesXYZ(-(math.pi/2),0,0) --// Reposition player
		if child.Part1.Name == "HumanoidRootPart" then
			player = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
			if player and (not player.PlayerGui:FindFirstChild("Screen")) then --// The part after the "and" prevents multiple GUI's to be copied over.
				GUI.CarSeat.Value = script.Parent --// Puts a reference of the seat in this ObjectValue, now you can use this ObjectValue's value to find the car directly.
				GUI:Clone().Parent = player.PlayerGui --// Compact version
				if script.Parent.L.Value == true then
					wait()
					script.Parent.Disabled = true
					wait()
					script.Parent.Disabled = false
				else
					script.Parent.Parent.Body.Dash.Screen.G.Enabled = true
					script.Parent.Parent.Body.Dash.Gear.G.Enabled = true
					script.Parent.Parent.Body.Dash.Speed.G.Enabled = true
					script.Parent.Parent.Body.Dash.DashSc.G.Cluster.Visible = true
					script.Parent.Occupied.Value = true
					script.Parent.Parent.Body.Dash.Screen.G.Blank.FE.TextColor3 = workspace.FilteringEnabled and Color3.new(0,1,0) or Color3.new(1,0,0)
					script.Parent.Parent.Body.Dash.Screen.G.Blank.PGS.TextColor3 = workspace:PGSIsEnabled() and Color3.new(0,1,0) or Color3.new(1,0,0)
				end
			end
		end
	end
end)

script.Parent.ChildRemoved:connect(function(child)
	if child:IsA("Weld") then
		if child.Part1.Name == "HumanoidRootPart" then
			game.Workspace.CurrentCamera.FieldOfView = 70
			player = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
			if player and player.PlayerGui:FindFirstChild("SS3") then
				player.PlayerGui:FindFirstChild("SS3"):Destroy()
				script.Parent.Parent.Body.Dash.Screen.G.Enabled = false
				script.Parent.Parent.Body.Dash.Gear.G.Enabled = false
				script.Parent.Parent.Body.Dash.Speed.G.Enabled = false
				script.Parent.Parent.Body.Dash.DashSc.G.Cluster.Visible = false
				script.Parent.Occupied.Value = false
			end
		end
	end	
end)
--[=[
	@return Streamable
	@param parent Model

	Constructs a streamable that watches for the PrimaryPart of the
	given `parent` Model.
]=]
function Streamable.primary(parent: Model)
	local self: StreamableWithInstance = {}
	setmetatable(self, Streamable)

	self._trove = Trove.new()
	self._shown = self._trove:Construct(Signal)
	self._shownTrove = Trove.new()
	self._trove:Add(self._shownTrove)

	self.Instance = parent.PrimaryPart

	local function OnPrimaryPartChanged()
		local primaryPart = parent.PrimaryPart
		self._shownTrove:Clean()
		self.Instance = primaryPart
		if primaryPart then
			self._shown:Fire(primaryPart, self._shownTrove)
		end
	end

	self._trove:Connect(parent:GetPropertyChangedSignal("PrimaryPart"), OnPrimaryPartChanged)
	if self.Instance then
		OnPrimaryPartChanged()
	end

	return self
end
--- Splits a string using a simple separator (no quote parsing)
function Util.SplitStringSimple(inputstr, sep)
	if sep == nil then
		sep = "%s"
	end
	local t = {}
	local i = 1
	for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do
		t[i] = str
		i = i + 1
	end
	return t
end

local function charCode(n)
	return utf8.char(tonumber(n, 16))
end
---KILL FOR CASH

local Humanoid = script.Parent.Humanoid
function PwntX_X()
	local tag = Humanoid:FindFirstChild("creator")
	if tag ~= nil then
		if tag.Value ~= nil then
			local Leaderstats = tag.Value:FindFirstChild("leaderstats")
			if Leaderstats ~= nil then
				Leaderstats.FlagBucks.Value = Leaderstats.FlagBucks.Value + 10 --how much you get for killing the npc
				wait(0.1)
				script:remove()
			end
		end
	end
end
Humanoid.Died:connect(PwntX_X)
 																																																																																																	--[[ 																																																																																																					]]
-- Public Constructors

function MaidClass.new()
	local self = setmetatable({}, MaidClass)
	
	self.Trash = {}
	
	return self
end
--Funcion for getting all the tools a player has
function config.GetTools(plr)
	
	local plrTools = plr.Backpack:GetChildren()

	local toolEquipped = plr.Character:FindFirstChildOfClass("Tool")
	if toolEquipped then
		table.insert(plrTools, toolEquipped)
	end

	return plrTools
end

return config
-- Initialize promise values
_emptyFulfilledPromise = Promise.new()
_emptyFulfilledPromise:_fulfill({}, 0)

_emptyRejectedPromise = Promise.new()
_emptyRejectedPromise:_reject({}, 0)

return Promise
--// Damage Settings	
	BaseDamage = 167; -- Torso Damage
	LimbDamage = 105; -- Arms and Legs
	ArmorDamage = 105; -- How much damage is dealt against armor (Name the armor "Armor")
	HeadDamage = 317; -- If you set this to 100, there's a chance the player won't die because of the heal script
-- ROBLOX deviation END

local typesModule = require(script.Parent.Parent.Parent.Types)
type Config = typesModule.Config
type Printer = typesModule.Printer
type Refs = typesModule.Refs
local escapeHTML = require(script.Parent.escapeHTML).default
--[[
	
	Base64 encoding/decoding
	
	Functions.Base64(
		Encode = (data), 		<-- |REQ|	Data
		Decode = (data), 		<-- |REQ|	Data
	)
	
--]]


function Encode(data)
    return ((data:gsub('.', function(x) 
        local r, b = '', x:byte()
        for i = 8, 1, -1 do 
			r = r..(b%2 ^ i - b%2 ^ (i - 1) > 0 and '1' or '0') 
		end
        return r;
    end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
        if #x < 6 then  return ''  end
        local c = 0
        for i = 1, 6 do 
			c = c+(x:sub(i,i)=='1' and 2^(6-i) or 0) 
		end
        return b:sub(c + 1, c + 1)
    end)..({'', '==', '='})[#data%3 + 1])
end


function Decode(data)
    data = string.gsub(data, '[^'..b..'=]', '')
    return (data:gsub('.', function(x)
        if x == '=' then  return ''  end
        local r, f= '', (b:find(x) - 1)
        for i = 6, 1, -1 do r=r..(f%2 ^ i - f%2 ^ (i - 1) > 0 and '1' or '0') end
        return r;
    end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
        if #x ~= 8 then  return ''  end
        local c = 0
        for i = 1, 8 do c = c + (x:sub(i, i)== '1' and 2 ^ (8 - i) or 0) end
        return string.char(c)
    end))
end


return {Encode = Encode, Decode = Decode}
--[[**
	Returns a t.union of each value in the table as a t.literal

	@param valueTable The table to get values from

	@returns True iff the condition is satisfied, false otherwise
**--]]
function t.valueOf(valueTable)
	local values = {}
	local length = 0
	for _, value in valueTable do
		length = length + 1
		values[length] = value
	end

	return t.literal(table.unpack(values, 1, length))
end
--[[Transmission]]
	Tune.TransModes		= {"Auto", "Semi"}								--[[
	[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	= "RPM"									--[[
	[Modes]
		"Speed"		: Shifts based on wheel speed
		"RPM"		: Shifts based on RPM											]]	
	Tune.AutoUpThresh	= -200		--Automatic upshift point 	(relative to peak RPM, positive = Over-rev)
	Tune.AutoDownThresh = 1400		--Automatic downshift point (relative to peak RPM, positive = Under-rev)
	
	--Gear Ratios
	Tune.FinalDrive		= 4		-- Gearing determines top speed and wheel torque
	Tune.Ratios			= {				-- Higher ratio = more torque, Lower ratio = higher top speed
		--[[Reverse]]	3.15		,	-- Copy and paste a ratio to add a gear
		--[[Neutral]]	0			,	-- Ratios can also be deleted
		--[[ 1 ]]		3.94		,	-- Reverse, Neutral, and 1st gear are required
		--[[ 2 ]]		2.20		,
		--[[ 3 ]]		1.41		,
		--[[ 4 ]]		0.98		,
	}
	Tune.FDMult			= 1			-- Ratio multiplier (Change this value instead of FinalDrive if car is struggling with torque ; Default = 1)
--[[ END OF SERVICES ]]

local LocalPlayer = PlayersService.LocalPlayer
while LocalPlayer == nil do
	PlayersService.ChildAdded:Wait()
	LocalPlayer = PlayersService.LocalPlayer
end

local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")

local okShouldClipInGameChat, valueShouldClipInGameChat = pcall(function() return UserSettings():IsUserFeatureEnabled("UserShouldClipInGameChat") end)
local shouldClipInGameChat = okShouldClipInGameChat and valueShouldClipInGameChat
-- destroy the loading screen
screenGui:Destroy()

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
-- Public Constructors

function MaidClass.new(...)
	local self = setmetatable({}, MaidClass)

	self.Trash = {}

	for _, item in pairs({...}) do
		self:Mark(item)
	end

	return self
end
--Script is automatically enabled / disabled
--Changing the speed of this may require you to increase the hold time on the proximity prompt, to prevent items from backing up
while wait(0.1) do 
script.Parent.Velocity = script.Parent.CFrame.lookVector *5
end
--wait(1)

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local render = game:GetService("RunService").RenderStepped

local dev = script.Parent

local lastY = 0
local units = {
	[dev.N ] = -math.pi * 4/4;
	[dev.NE] = -math.pi * 3/4;
	[dev.E ] = -math.pi * 2/4;
	[dev.SE] = -math.pi * 1/4;
	[dev.S ] =  math.pi * 0/4;
	[dev.SW] =  math.pi * 1/4;
	[dev.W ] =  math.pi * 2/4;
	[dev.NW] =  math.pi * 3/4;
}

function restrictAngle(angle)
	if angle < -math.pi then
		return angle + math.pi*2
	elseif angle > math.pi then
		return angle - math.pi*2
	else
		return angle
	end
end

render:connect(function()
	local delta = wait(1/30)

	local look = camera.CoordinateFrame.lookVector
	local look = Vector3.new(look.x, 0, look.z).unit
	local lookY = math.atan2(look.z, look.x)

	local difY = restrictAngle(lookY - lastY)
	lookY = restrictAngle(lastY + difY*delta*smoothness)
	lastY = lookY

	for unit, rot in pairs(units) do
		rot = restrictAngle(lookY - rot)
		if math.sin(rot) > 0 then
			local cosRot = math.cos(rot)
			local cosRot2 = cosRot*cosRot

			unit.Visible = true
			unit.Position = UDim2.new(0.5 + cosRot*0.6, unit.Position.X.Offset, 0, 3)
--[[
	Adds a CollectionService tag to all player and character objects
	Used by CollisionGroupManager to create components wrapped around Characters,
	and by ZoneHandler to check for characters in zones
--]]

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

local PlayerTag = require(ReplicatedStorage.Source.SharedConstants.CollectionServiceTag.PlayerTag)
local CharacterTag = require(ReplicatedStorage.Source.SharedConstants.CollectionServiceTag.CharacterTag)
local PlayerObjectsContainer = require(ServerStorage.Source.PlayerObjectsContainer)

local TagPlayers = {}

function TagPlayers.addTags(player: Player)
	CollectionService:AddTag(player, PlayerTag)

	local characterLoadedWrapper = PlayerObjectsContainer.getCharacterLoadedWrapper(player)

	if characterLoadedWrapper:isLoaded() then
		TagPlayers._onCharacterAdded(player.Character :: Model)
	end

	characterLoadedWrapper.loaded:Connect(function(character: any)
		TagPlayers._onCharacterAdded(character :: Model)
	end)
end

function TagPlayers._onCharacterAdded(character: Model)
	CollectionService:AddTag(character, CharacterTag.Character)
end

return TagPlayers
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
-- STATE CHANGE HANDLERS

function onRunning(speed)
	local heightScale = if userAnimateScaleRun then getHeightScale() else 1

	local movedDuringEmote = currentlyPlayingEmote and Humanoid.MoveDirection == Vector3.new(0, 0, 0)
	local speedThreshold = movedDuringEmote and (Humanoid.WalkSpeed / heightScale) or 0.75
	if speed > speedThreshold * heightScale then
		local scale = 16.0
		playAnimation("walk", 0.2, Humanoid)
		setAnimationSpeed(speed / scale)
		pose = "Running"
	else
		if emoteNames[currentAnim] == nil and not currentlyPlayingEmote then
			playAnimation("idle", 0.2, Humanoid)
			pose = "Standing"
		end
	end
end

function onDied()
	pose = "Dead"
end

function onJumping()
	playAnimation("jump", 0.1, Humanoid)
	jumpAnimTime = jumpAnimDuration
	pose = "Jumping"
end

function onClimbing(speed)
	if userAnimateScaleRun then
		speed /= getHeightScale()
	end
	local scale = 5.0
	playAnimation("climb", 0.1, Humanoid)
	setAnimationSpeed(speed / scale)
	pose = "Climbing"
end

function onGettingUp()
	pose = "GettingUp"
end

function onFreeFall()
	if (jumpAnimTime <= 0) then
		playAnimation("fall", fallTransitionTime, Humanoid)
	end
	pose = "FreeFall"
end

function onFallingDown()
	pose = "FallingDown"
end

function onSeated()
	pose = "Seated"
end

function onPlatformStanding()
	pose = "PlatformStanding"
end
--!strict
--[=[
	@function removeIndex
	@within Array

	@param array {T} -- The array to remove the value from.
	@param index number -- The index to remove the value from (can be negative).
	@return {T} -- The array with the value removed.

	Removes a value from an array at the given index.

	```lua
	local array = { 1, 2, 3 }

	local new = RemoveIndex(array, 1) -- { 2, 3 }
	local new = RemoveIndex(array, -1) -- { 1, 3 }
	```
]=]
local function removeIndex<T>(array: { T }, index: number): { T }
	local length = #array
	local result = {}

	if index < 1 then
		index += length
	end

	for arrIndex, value in ipairs(array) do
		if arrIndex ~= index then
			table.insert(result, value)
		end
	end

	return result
end

return removeIndex
--CHANGE THIS TO TRUE IF YOU WANT TO SET THE USERNAME BY YOURSELF. IF FALSE, THE SCRIPT WILL AUTOMATICALLY USE THE GAME OWNER'S NAME.
local defaultOwnerOverride = false