Best way to play an animation in the client from a different client

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to know the best way to do if the player A hits player B, then player B will play an animation

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried to add a BoolValue so when player A hits the player B, player B’s BoolValue turns on, running the function using Boolean.Changed. But I want to know if there is a better way of doing it?

I have also tried to play an animation in player B, from player A’s local script but only player A could see the animation being played on player B

Well, with a Touched event, you can get the opponents Humanoid and play the animation there.

p.Touched:Connect(function(hit)
   if (hit.Parent:FindFirstChild("Humanoid")) then
       local hum = hit.Parent.Humanoid --gets humanoid here
       local Animator = hum.Animator --use this to play animations
       --you can play the animation for the other client or player here
   end
end)

This might not be correct but, I’ll do some research and come back to this post.

Please see:

You should play player B’s animation on server, same with dealing the damage and such. Otherwise it can get exploitable.

1 Like

Dont forget, humanoid:LoadAnimation() is deprecated! Use humanoid.Animator:LoadAnimation() instead!

Ah yes, I forgot it was deprecated, Thank you Dr :smiley:

this works but it doesn’t replicate? only player A could see the animation being played on player B

Thank you! I’ll do this instead!