local function t(Z)local u=Z.Character:WaitForChild("\072\117\109\097\110\111\105\100")local B=u:WaitForChild("\072\117\109\097\110\111\105\100\068\101\115\099\114\105\112\116\105\111\110")emoteManager:setup(Z,B)local a a=u.Died:Connect(function()stopEmote(Z)Z.CharacterAdded:Wait()t(Z)a:Disconnect()end)end local function Z(Z)if not Z.Character then Z.CharacterAdded:Wait()end t(Z)end local function u(t)stopEmote(t)emoteManager:cleanup(t.UserId)end local function B(t,Z,u)assert(onChangeEmoteLockCheck(Z,u))emoteManager:setEmoteIsLockedForPlayer(t,Z,u)end emotePlayed.OnServerEvent:Connect(startEmote)emoteStopped.OnServerEvent:Connect(stopEmote)changeEmoteLock.OnServerEvent:Connect(B)Players.PlayerAdded:Connect(Z)Players.PlayerRemoving:Connect(u)loadEmoteAssets()
--[[
	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()
