Currently I want to make a panel where you can display your character, but the problem is that I want to connect the player’s animations to the model located inside a “WorldModel” instance.
Do you guys have any ideas on how to do this? The only thing I could think of is to use this to detect the active animations:
local player = game:GetService("Players").LocalPlayer
for i, v in pairs(player.Character.Humanoid:GetPlayingAnimationTracks()) do
print(i, v) -- v = AnimationTrack
end
local function UpdateAnim(Char, CloneChar)
local timeAnimations = {
["walk"] = 0.2,
["idle"] = 0.2,
["jump"] = 0.1,
["climb"] = 0.1,
["fall"] = 0.2,
["swimidle"] = 0.4,
["swim"] = 0.4,
["sit"] = 0.5,
}
if #CloneChar.Humanoid:GetPlayingAnimationTracks() > #Char.Humanoid:GetPlayingAnimationTracks() then
for i = #CloneChar.Humanoid:GetPlayingAnimationTracks(), #Char.Humanoid:GetPlayingAnimationTracks(), -1 do
CloneChar.Humanoid:GetPlayingAnimationTracks()[i]:Stop()
CloneChar.Humanoid:GetPlayingAnimationTracks()[i]:Destroy()
end
end
for i, v in pairs(Char.Humanoid:GetPlayingAnimationTracks()) do
if not CloneChar.Humanoid:GetPlayingAnimationTracks()[i] then
local anim = CloneChar.Humanoid.Animator:LoadAnimation(
CloneChar.Animate[v.Animation.Parent.Name][v.Animation.Name]
)
anim:Play(timeAnimations[v.Animation.Parent.Name] or 0.1)
end
if CloneChar.Humanoid:GetPlayingAnimationTracks()[i].Animation.AnimationId ~= v.Animation.AnimationId then
for k = #CloneChar.Humanoid:GetPlayingAnimationTracks(), i, -1 do
CloneChar.Humanoid:GetPlayingAnimationTracks()[i]:Stop()
CloneChar.Humanoid:GetPlayingAnimationTracks()[i]:Destroy()
end
local anim = CloneChar.Humanoid.Animator:LoadAnimation(
CloneChar.Animate[v.Animation.Parent.Name][v.Animation.Name]
)
anim:Play(timeAnimations[v.Animation.Parent.Name] or 0.1)
end
end
end
local newChar = game.Players.LocalPlayer.Character:Clone()
while true do
task.wait()
UpdateAnim(game.Players.LocalPlayer.Character, newChar)
end