Hello, thanks for reading in advance.
I was trying to script a weapon, it has a custom rig and animations, however I couldn’t succeed playing animations from client. Weapon’s network owner is player.
I worked pretty hard on that, although no success so far. Then I tried to test this, umm, feature? In a fresh-new place. I put down four R15 rigs. Two with humanoid, two with AnimationController, player has only HRP Network ownership on two, on other two player has all parts’ ownership. Still, no luck. Here is repo repo.rbxl (571.7 KB)
Is this feature broken or am I doing something wrong? Here’s wiki page that tells I can play animations from client if client has network ownership.
FINAL EDIT FOR LATE-READERS:
We all came to a conclusion together and the next eight comments are the solution to this problem from different aspects. Thanks for reading.
Giving a player network ownership won’t replicate animations to the server. The wiki page is stating that animations should only be played by the server if the server has network ownership of a model’s primary part.
In your case, all animations should be loaded and played locally for all clients.
Why would it be a problem to load the animation on the server? According to the wiki, using the server is a viable option for loading the animation, unless you have created the animation controller object via client-side.
It’s only a problem if you’re loading an animation on a model (In this case it’s a player) with it’s network ownership set to a player. There is a very noticeable delay that can be seen by the player who has the network ownership which is the main reason why Roblox handles all player animations locally in the first place.
The wiki page for Humanoid:LoadAnimation() even advises to load animations locally if a model is controlled by a player.
Regardless of whether you should, or should not load animations on the server or client, giving a player network ownership will not replicate any animations loaded and played by the network owner.
I recommend using remote events, and telling the other clients to play a specific animation for the specific client’s character so that other clients see the animation… All of the player animations should be handled on the client side (with a simple remote event setup so that one client can bounce the data to the other clients from the server). You want that specific client to handle the animation as soon as possible so that there is no noticeable latency - for the other clients, it doesn’t matter as much because there will be latency either way.
I would completely ignore network ownership for your player animations.
If you handle the animations on the server, there will be noticeable latency for that specific client, and it would be the same case for all of the other users’ animations.
What about games using custom rigs as players? How do their animations replicate? For example, I am pretty sure Vesteria has custom rigs for players. Is that only about player’s character property? Only that allows animations to replicate?
It took two reads but I got what you’re saying
Yeah it sounds pretty logical, and I guess I am going with this if the other way doesn’t work. Either this or viewmodel, and I honestly hate viewmodels. Thanks!
Although it is not exact solution to the question, so can’t mark as solution. Sorry
I may be wrong, but from berezaa’s stream it looks like animations are played whenever the player’s hitbox state property changes.
Since character models on my game are created locally, the server can’t load or player animations since the model doesn’t actually exist on the server. My game uses custom player objects and replicates all character state changes to all player through remote events. As soon as a state change is detected, the clients will play the animation associated with the current state.
It’s virtually the same concept that the default roblox animation script uses, except the default roblox animation script observes changes from humanoid instances.
player 1: Decides to play an animation → play the animation within the local script for this player → at the same time, send a remote event call to the server with the following arguments: player instance (by default) , “animation”, animation_name.
Server: The server just received the remote event call from that particular client with the following arguments: player instance, “animation”, animation_name… Next, the server will loop thru the list of other players, and send them a remote event call with the following arguments: player instance, “animation”, animation_name…
Player 2: Player two just received the a call from the server with the following arguments: player instance, “animation”, animation_name… Based off the remote event data, player 2’s local script determines that the data is for an animation… Next, Player 2 handles Player 1’s animation within their own local script…
Success
I didn’t include any actual code because people tend to have very different remote event setups, and I didn’t want to throw you off with my own code setup - and pseudo-code is easier to understand and write…
I made a similar post about a month ago which might be helpful (this topic deals with handling animation replication and making sure there isn’t animation overlap) Player Animation Replication
(I would ignore most of the posts in the link above, and simply just look at the solution which was solved by TheGamer101)
Alright, thanks for the help guys. I set up the system, didn’t test it yet but have no doubt either.
I can only mark one solution so sorry about that, this entire post is a solution itself.