Note! Im trying to make people able to reproduce this and test themself and maybe we can come to a conclusion on how to solve this case. Warning: There might be alot to read for those who like short questions.
I have noticed passing animationtrack client to server or opposite results in nil. So for a workaround on this I tried firing off the animation in the serverscript and hopefully get the animation by using "GetPlayingAnimationTracks"
1st attempt
-- Comments --- --LocalScript in a textbutton in a gui. This is an invokeserver -- The returnvalue should be the animationtrack -------------------------------------------------------- mouse.Button1Down:Connect(function() local Track = Action:InvokeServer() print(Track ) end) -- Comments -- -- ServerScript [placed in serverscriptservice] -- Inside the ServerScript there is a folder named Animations -- Inside this folder there are several animations objects -- Our target animation will be the object named "Attack1" -------------------------------------------------------- Action.OnServerInvoke = function(player) local Attack1 = script.Animations:WaitForChild("Attack1") local Track = char.Humanoid:LoadAnimation(Attack1) print(Track ) Track:Play() return Track
-- Output -- client --> nil -- Server --> Attack1
2nd attempt -- given that we have char which is the character and humanoid -- The code below will return an array of the AnimationTracks currently being played on the Humanoid.
for _,anim in pairs(char.Humanoid:GetPlayingAnimationTracks()) do print(anim.Name) end
With this we can do a workaround to get the animation instead of nil
-- Client local player = game.Players.LocalPlayer local char = player.Character if not char or not char.Parent then char = player.CharacterAdded:wait() end mouse.Button1Down:Connect(function() local Track = Action:InvokeServer() for _,anim in pairs(char.Humanoid:GetPlayingAnimationTracks()) do print(anim.Name) end end) -- Server Action.OnServerInvoke = function(player) local char = player.Character local Attack1 = script.Animations:WaitForChild("Attack1") local Track = char.Humanoid:LoadAnimation(Attack1) Track:Play() for _,anim in pairs(char.Humanoid:GetPlayingAnimationTracks()) do print(anim.Name) end return
NOTE! there are other animations playing with different names but those are of no concern for this test
print returns
-- Client --> Animation -- Server --> Attack1
I have tried to change the name of the track in the serverscript
Taken from the serverscript
local Attack1 = script.Animations:WaitForChild("Attack1") local Track = char.Humanoid:LoadAnimation(Attack1) Track.Name = "TestName" Track:Play()
print returns
-- Client --> Animation -- Server --> TestName
Isn't this great you may ask. Now we have the animation even when the server returned nil The problem would occur if you played many animations in the serverscript
-- Client --> Animation, Animation, Animation -- Server --> Attack1, Attack2, EquipTool
Now how would you get the specific animationtrack because they all have the same name ????
Sincerely: Hakurem
I tried this before, and attempted to send my AnimationTrack from the client to server using remotes and it always returns nil.
You don't have to use remotes on animations with FilteringEnabled on. Just run the animations in the LocalScript and it should play fine for both client and servers. Remember to always set the priority in the animation plugin, or Roblox's Default animations will keep interrupting your animation.
https://www.roblox.com/games/51410992/FE-Testing
This is my testing place where I test my gun script out. (Currently testing my animations and fixing a few bugs. Having problems with the animations, the arms don't move only the head moves when I reload. However, if I rejoin the game a few times, it fixes and the animations run fine. I think this is a bug on Roblox's side.)