If you’re changing the humanoid state of a unanchored character, it has to change.
If it’s a anchored character, you cannot change its state. It will always default to FallingDown.
The core issue is that you’re rushing with your prints, if you replace task.spawn with task.delay, you will notice a difference as to what it outputs.
The behavior when you switch the NetworkOwner to a client is a bit different, because you’re using a server-script, the moment you switch it over to a client, the client thinks that the NPC is at older state only if the client hasnt noticed the new state in time.
The likely reason is something related to how server tries to replicate changes made so other clients basically notice and see it, the moment you change the ownership from server to a client, now the client blindly trusts it’s own state instead of what the server said right after setting the ownership, so it cancels out that state change the server wanted to operate before changing the ownership.
And so, if the client doesnt replicate that wanted state change in time, you get these issues.
Putting a delay and changing the state of the humanoid first to Physics, waiting a player’s ping amount of seconds (GetNetworkPing) multiplied by 2 and then switching the NetworkOwnership to that client is the only close fix, however if the client’s ping is up to 5000ms+ it would still cause inaccuracy.
The only thing you could really do as far as i know, is:
Change the ownership very late, basically to let the client acknowledge the state change first.
Use remote events
Switch the script context to client (although you wont be able to set the network ownership and you’d need to exclude even more states)
Or dont switch ownership at all (only if you dont need to rely on what a client thinks)