Humanoid ignores inputs when creating client side characters

My game uses a custom character system where each individual client creates their own characters (and other players characters) by cloning the servers reference to the model and then deleting it locally. This works perfectly fine most of the time, however rarely and very inconsistently you won’t be able to move your own character because Humanoid.MoveDirection does not update (this also applies to jumping).

This place file has a demo of how I do this, but be aware that getting this bug to happen is fairly rare.
ReplicationTest.rbxl (65.8 KB)

Some additional info:

  • Deleting the Humanoid in the character and replacing it with a new locally made one does not resolve the issue.
  • Adding any sort of wait/delay before setting Player.Character also does not resolve the issue.

I’d appreicate if an engineer could look into what conditions must be met for Humanoid input to register to help me resolve this problem (or even better a fix is pushed).

2 Likes

Looks like you’re sending a remote event from server to client with a Model reference of a Model you’ve just created, and then the client script is trying to Clone() it without waiting for it to replicate? The server script appears to make an extra clone of the character unnecessarily. You may also have 1 or more race conditions with the PlayerScripts because of replication timings or ordering of CharacterAdded/CharacterRemoved.

Most games that have local-only characters don’t have the extra server-side cloning or the remote event, they just wait for the character’s avatar to replicate normally to the client, then clone and delete it on the client. The only sort of gotcha is to know that setting Player.Character fires CharacterAdded, so you have to make sure that you don’t have an infinite loop of cloning the clone. You can just mark the clone with an attribute, valueObject, or save a reference to the last-created clone to prevent this re-entrancy.

Not an engine bug BTW, this is a race condition (or multiple) in your own code.

2 Likes

Appreciate the reply. The reason I used an event over character added/removing was to ensure the character had fully loaded on the client because I assume instance replication uses the same network queue as reliable events. Do you happen to know if this is the case? I can’t find a concrete answer on it anywhere.

1 Like

Definitely not the same queue! Instance replication and remote events are handled completely separately, and even if they weren’t, there would be no future guarantee that this wouldn’t change. The correct ways to wait for a replicating instance is are with WaitForChild or by using a loop that checks if a particular instance path is nil and waits on the appropriate event to check again. e.g. ChildAdded or DescendantAdded in most cases.

2 Likes

This is just an acknowledgment announcement!

We’ve filed a ticket to our internal database, and we’ll follow up when we have an update!

Thanks for the report!

Salutations!
As stated above, this is intended behaviour.
Thanks!