Is there a way to change a humanoid loaded animation name on roblox?

Im trying to make a sync animation for players, where 1 player can sync his animation to the other player. Im facing an issue, I can’t detect which animation (that the other player is playing) is the dance animation. Is there a way to give the animations that get loaded a name and not just keep it animation?
I tried changing:

v.Name = "emote" 
Humanoid:Loadanimation(v)``` 
but it didnt work. 

Sync source code: (SERVER SCRIPT)
```lua
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")

local players_tbl = {}
local sync_pattern = "/sync ([%w_]+)"
local unsync_command = "/unsync"


local function sync(player, target)
	local animator1 = player.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
	local animator2 = target.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
	
	for i,v in pairs(animator2:GetPlayingAnimationTracks()) do
		print("Name: ",v.Name,"Speed: ",v.Speed,"Attribute: ",v:GetAttribute("Emote"))
	end
	
end

RS.Sync.OnServerEvent:Connect(function(player, target)
	if target and target:IsA("Player") then
		
		local now = tick()
		local LastUsed = players_tbl[player] or 0
		if now - LastUsed > 3 then
			players_tbl[player] = now
			sync(player,target)
		end
	end
	for i,v in pairs(players_tbl) do
		print(i , ":", v)
	end
end)

Source code of animation loading: (LOCAL SCRIPT)

v.Name = "Emote"
				local loadedAnim = humanoid:WaitForChild("Animator"):LoadAnimation(v)
				loadedAnim:SetAttribute("Emote",true)
				loadedAnim.Looped = true
				loadedAnim.Priority = Enum.AnimationPriority.Action

All help is appreciated!

1 Like

this is what I get:
image

AnimationTracks don’t have a name variable that you can change, but they do have an AnimationID that you can read from. You could just add all your emote id’s into a big table and check every animation playing and if it matches.

local TrackTable = {
    --/ AnimationIDs here
}
for _, AnimationTrack: AnimationTrack in Animator:GetPlayingAnimationTracks() do
   if not table.find(TrackTable, AnimationTrack.Animation.AnimationId) then
      return
   end

   --your logic here
end
1 Like

I also have some further questions. In this sync system, I don’t understand why animations wont sync. The player that sync is always around 2 seconds delayed.

local function sync(player, target)
	local animator1 = player.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
	local animator2 = target.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
	local anims = getAllAnimId()
	
	for i,v in pairs(animator2:GetPlayingAnimationTracks()) do
		local trackId = getNumber(v.Animation.AnimationId)
		local index = table.find(anims,trackId)
		
		if(index)then
			-- here is the problem: Its delayed ??
			local anim = animator1:LoadAnimation(v.Animation)
			local temp_timeStamp =
			anim:AdjustSpeed(v.Speed)
			
			anim.TimePosition =  v.TimePosition
			anim:Play()
			break;
		end
	end
	
end

All help is appreciated!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.