FE Player Animations

This is the case with most objects, but not with Animations. Animations played locally on the client will replicate. That’s why when you see other players walking ingame their movement seems so smooth and quick; it is being replicated to other clients.

Now to answer the OP, I think you are trying to replicate the animation only to the particular client, without it replicating? I’m not entirely sure how you might do this, since any animation track created on the client will replicate.
Here are my ideas:

  • have the server destroy the animation, and then the client recreate it? This might not work, but hey might as well try it.
  • load the animation into an AnimationController that is created locally? Haven’t tested this, so it may cause errors.
  • Try parenting an animation to the client’s PlayerGui? this is one way to replicate things from server > one particular client. Also haven’t tested this.
  • Alternatively, if you could somehow recreate the animation with Lerp or TweenService, that is a surefire way to not replicate.
5 Likes

Not sure where you guys are getting this information from. Animations don’t replicate, the transformations on the Motor6Ds in the character replicate because the character is network owned by the client.

Just have the tool owner play the animation and leave it at that. Make sure the animation instance is in the DataModel at compile time (don’t create it at run time), otherwise that animation won’t replicate. Exception goes for if the server creates the animation and doesn’t parent it to a server-only container.

If you’re looking for client-only animations and to void replication, I don’t think you can. The client will overwrite the changes another client attempts to apply and the client itself will automatically replicate the movements of the character.

4 Likes

A.k.a, the animations replicate :stuck_out_tongue:

our statements weren’t wrong; we just didn’t explicitly state how they replicate.

3 Likes

So basically, if I make the animation instance during run time (using a local script), they will not replicate to the other clients? If so, that would solve my problem, and I can keep working on my current animation framework implementation (for my game).

2 Likes

would this work? (If I made the animation instance during run-time) ^

(post must be at least 30 characters)

2 Likes

@ndrwcswll

No, they don’t. Animations are objects that hold ContentIds from an asset. Animation objects follow the same replication pattern that any other instance does.

Animation replication =/= Physics replication

Yes they are wrong. Animations and the physics applied to characters (by extension, the setting of Transform properties on Motor6Ds, which is controlled by the physics engine) are completely different.


@TheAviator01

I believe they’ll still replicate. You can set up a quick repro in Studio and use a Local Test Server of 2 players to test this out. Player1 should play an animation created by them through a LocalScript. If Player2 can see it, then the movements are replicating. If not, then they aren’t (which would then be the solution to your problem).

3 Likes

AnimationTracks** I get the two mixed up sometimes. AnimationTracks do cross the client/server boundary, as you can find the playing animations on the server

3 Likes

AnimationTracks don’t replicate either, because they are also instances. AnimationTrack is an object that controls the playback of animations. It can only be “created” from LoadAnimation of a Humanoid or an AnimationController, but that doesn’t mean it still doesn’t follow standard replication patterns.

The only thing that replicates is the movement applied from the AnimationTrack to any relevant Motor6Ds. The client network owns their character and thus the movements they apply replicate. This isn’t an exception for animations, since animations are movements of CFrames.

Also see: https://developer.roblox.com/api-reference/class/Pose (substantiation for the second paragraph)

4 Likes

But simply moving Motor6D’s locally will not replicate (not using animations)?

2 Likes

I am going to test this idea in roblox studio… I’ll be back

Here is some code I was testing:

wait(1)

local player = game.Players.LocalPlayer

local char = player.Character
local h = char.Humanoid

local animation = Instance.new("Animation")
animation.Parent = h
animation.AnimationId = "http://www.roblox.com/asset/?id=507771019"

local current = h:LoadAnimation(animation)
current.Priority = Enum.AnimationPriority.Action

current:Play(0.5,1,3)


print("running")

(The code above is pretty bad, it just provides a rough example of the general idea)

Testing it:

  • put the code in a local script
  • put the local script inside a screen GUI within the starter GUI

When I ran it on client mode, the animation played, but when I tested it on a test server w/ 2 players, none of their animations played…

2 Likes

I’m not too sure about the other Motor6D properties since there’s no statements saying that the properties aren’t replicated across the client/server boundary, but animations only manipulate the Transform CFrame. Setting Transform from a script doesn’t replicate, though animations can set it and it will replicate.

Here’s a thread regarding Transform that may be able to explain:

tl;dr

  • Transform was an internal property used by animations
  • Setting Transform from scripts doesn’t replicate
  • Animations can still internally overwrite Transform (which explains its behaviour)

A couple of us were discussing it on the New Member Discord, I think we’ve reached an interesting discussion about it so far?

3 Likes

Despite my lack of understanding of replication, if player 2 decides to animate player 1 from their own local environment, will it affect player 1 (in the perspective of player 1)?

2 Likes

Funny you asked! I was trying out a model similar to this and you happened to post a question just as I was typing up a response to your previous post. I’m not too sure what I’m doing either, but I seem to have cracked the case on this one. Check below.


Ouch, yeah I see what happened. I threw this code unedited into my game; the client was dancing fine, but on the server and the other client, they weren’t (I changed the AnimationId to the dance one). However, all is not lost; I seem to have figured something out.

Instead of having the script create the animation, I stored the Animation in the DataModel (specifically in ReplicatedStorage, so the object would be there at compile time instead of being created at run time). I then had one of the clients call the dancing animation on the other player; it seems to have gotten the results you were seeking.

This may require some testing on your part to confirm if this is what you need, but I think this should do.

3 Likes

Can you send me a screenshot of your replicated storage layout (so that I can see how you organized everything)

This looks like the solution :slight_smile:

Edit** oops, I realized that I can see your replicated storage view from the post above.

2 Likes

image

On Player2, I wrote the following code into my command bar:

workspace.Player1.Humanoid:LoadAnimation(game.ReplicatedStorage.Animation):Play()

Player2 (the client on the right side) was dancing from a LocalScript in PlayerScripts containing the repro code you supplied - that part you can ignore. On the Player2 client, I called the above code and Player1 started dancing on Player2’s screen. Player1’s screen did not show that they were dancing and neither did the server.

ADDITION: One issue. Once Player1 starts moving or playing it’s own animations, the animation that Player2 called will get overwritten. Forgot to test for this, just did so now. Moving Player1 cancelled the local animation on Player2.

Wouldn’t call this a reliable solution, or one at all. It certainly seems to have done what you were looking for, but it becomes moot once Player1 moves around or plays an animation itself.

3 Likes

Would it be possible to get a copy of your testing place for this? I can’t get the animations to run

my local script code:

local player = game.Players.LocalPlayer

local char = player.Character
local h = char.Humanoid

local animation = game.ReplicatedStorage.Animation
animation.AnimationId = "http://www.roblox.com/asset/?id=2097675014"

h:LoadAnimation(animation):Play()

image

It works when I test it in solo / client local mode

2 Likes

I mean, you can, but there isn’t really much (or anything) on said test place.

AnimationRepro.rbxl (14.9 KB)

I just want to clarify for safety’s sake, which of these two scenarios are you trying to achieve?

  • Player1 plays animation on Player1. Player2 will not see Player1 animating.
  • Player1 plays animation on Player2. Player2 will not see themselves animating.

If it’s the first one, you can create the Animation object on the client and run it. I think I may have mentioned that already. As for the second one, well, that’s where the issue is occurring as per my previous post.

I was thinking of throwing together a hack where a pseudomodel would animate and then Transform of the target character would be set every frame to the pseudomodel’s movements, but that may be a little much.

6 Likes

Final solution:

I will have each player worry about their own character’s animation - considering that the Motor6Ds will replicate the character actions / movement.

Thanks again to everyone that contributed towards this thread, especially colbert2677 :slight_smile:

Edit** Thank you TheGamer101 :slight_smile:

2 Likes

I’m a bit late to this thread but there is a general solution to disabling replication of Animations that isn’t too difficult to achieve.

To animate a player character locally only you can replace the Animator object under the Humanoid with a new copy in a LocalScript. This will disable animation replication from that client.

For non player characters a local AnimationController should be used.

There is some more information in this thread:
https://devforum.roblox.com/t/disableanimationreplication-is-shipped/24859/24

8 Likes

Exploiters cannot play their own animations, The animation has to be owned by the game owner or the ROBLOX account.

3 Likes