How do I disable humanoid state types?

I plan on adding a semi large amount of simple NPCs that follow players in the game, they do not need to do much such as jumping, sitting etc, but stuff like checking magnitude every 0.5 seconds. I will only give it 2 hit animations, walk animation and being hit animation as well as maybe 2 special animations. I wish to keep this as performance friendly as possible. But I heard a while back someone mentioned to me about disabling humanoid states. I have given it a try, such as disabling humanoid sitting, but it appears that I can still sit etc.

Does this actually help performance? If so, how do I use this correctly?

https://developer.roblox.com/en-us/api-reference/function/Humanoid/SetStateEnabled

^ All the info you need to disable humanoid state types.

Edit: I am not sure how much this is going to actually effect performance. Maybe someone else can elaborate on that?

3 Likes

just helping you on your question, just fork the script and then modify it to your liking, and there, you got it.

SetStateEnabled. Could be found by searching.

Disabling HumanoidStateTypes that you don’t actively use can help with performance but make sure that you don’t rely on it as the single point of truth. Further optimisations will have to come from your code as well. Humanoids are expensive but your code can be as well.

This is something that might interest you if you’re working with large counts of NPCs and you’re starting to think about performance with Humanoids:

5 Likes

Ive noticed that you mentioned about rendering animations on the client, may you elaborate on this? Because the only way I can imagine doing this is :FireAllClients with the parameters being the NPC and what animation should be played on the client. Using this method, I would be using :FireAllClients hundreds of times per minute.

Frankly this is not my post so you’ll have to consult the thread’s creators via reply or direct messaging. In my experience though, I usually have some kind of state values under the Humanoid that determine what animations should be played. This still of course means some client-server transmission is going on but not through RemoteEvents. The only price to pay is extra instances in the DataModel.

1 Like