alright here’s the solution i found:
The problem was the fact i didn’t own the animation what you want to do is use InsertService and call InsertService:LoadAsset(AnimationId) from the server and extract the animation from there, here’s the function i got for extracting the animation (Worked in all test cases):
local AnimationTypes = {
"IdleAnimation",
"WalkAnimation",
"RunAnimation",
"JumpAnimation",
"FallAnimation",
"ClimbAnimation",
"SwimAnimation",
}
local AnimationNamesList = {
"idle",
"walk",
"run",
"jump",
"fall",
"climb",
"swim"
}
use the tables above to get the animationName and use the function below to extract the animation object
local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
function GetLoadedAnimation(AnimationModel: Model, AnimationName)
local KeyFrameSequence = AnimationModel:FindFirstChildWhichIsA('KeyframeSequence')
if KeyFrameSequence then
local HashId = KeyframeSequenceProvider:RegisterKeyframeSequence(KeyFrameSequence)
local Animation = Instance.new('Animation')
Animation.AnimationId = HashId
return Animation
end
local AnimationsList = AnimationModel:WaitForChild('R15Anim'):WaitForChild(AnimationName):GetChildren()
local TopWeight = 0
local TopWeightAnimation
if (#AnimationsList > 1) then
for _, Animation in AnimationsList do
local Weight = Animation:WaitForChild('Weight', 3)
if Weight and (Weight.Value > TopWeight) then
TopWeight = Weight.Value
TopWeightAnimation = Animation
end
end
else
TopWeightAnimation = AnimationsList[1]
end
return TopWeightAnimation
end
and lastly here’s the server-side code i’m using to retrieve the animations (Wouldn’t really recommend using remoteFunctions but it is what it is):
local InsertService = game:GetService('InsertService')
function YieldData(func, ...)
local Data
local success = false
local SearchIndex = 1
local args = {...}
while (not success) do
success = pcall(function()
Data = func(table.unpack(args))
end)
if (success) then break end
SearchIndex += 1
task.wait(SearchDelay)
end
return Data
end
local LoadedAnimations = {}
GetAnimation.OnServerInvoke = function(Player, AnimationId)
if (not AnimationId) then Player:Kick() end
AnimationId = tonumber(AnimationId)
local Animation = LoadedAnimations[AnimationId]
if (Animation) then return Animation end
Animation = YieldData(InsertService.LoadAsset, InsertService, AnimationId)
Animation.Parent = Animations
LoadedAnimations[AnimationId] = Animation
return Animation
end
Make sure to cache animations in case of multiple requests