In efforts to improve performance, the property Humanoid.FloorMaterial will no longer be replicated from client to server, and will instead be computed locally by the client and server when accessed.
Keep in mind that putting a listener on the FloorMaterial property will cause the FloorMaterial to be recalculated every step for non-local humanoids, which could be costly performance-wise, so we suggest trying to avoid putting listeners on them.
Thank you!
EDIT: This change will be live later today.
EDIT: To clarify, this property is not being removed. We are just no longer replicating it - the value will be computed locally on each the client and server. All functionality should remain the same.
so will code relying on just Humanoid.FloorMaterial return nothing if its not computed locally?
for example just a script doing
if Humanoid.FloorMaterial == Enum.Material.Plastic then
what would happen in that case would the floor material just be nil or will it be air?
I’ve had a few rare cases of FloorMaterial being nil in the past so I’m just curious
Also it may break any existing code that doesn’t listen for changes if it just returns nil
Sound great!
To clarify, though - since a performance degradation has been mentioned when listening on the server, would it be a better idea to raycast in a grid from the player’s feet, or listen to Humanoid.FloorMaterial instead? I currently do the former for my flight anti-cheat, and I’d like to know on the performance implications for the latter if possible. Any possible exploits that could come up would be great to know, too.
Many thanks!
Depends on how frequently you are performing this check, but if you add a listener, every simulation step the engine will also be performing raycasts to determine floor under the hood. So if you are not checking every step, I think performing raycast would be probably be better. Otherwise, there may be a slight benefit to listening to the Humanoid.FloorMaterial property instead.
In terms of exploits, I hypothesized that this might improve the anti-flight cheats since Clients can no longer spoof their FloorMaterial to the server. But don’t quote me on this.
In that code, we access the property Humanoid.FloorMaterial in the conditional statement, which would trigger local computation if FloorMaterial were unknown.
Additionally, FloorMaterial should now return AIR_MATERIAL if nil / unknown.
If it is not advised to listen to changes of the property, how would one make systems that depend on knowing the value all the time, like having different walk speeds on different materials?
I’m not sure how big this performance actually is, however one thing you can do, is write your own code to check if something changed, then just not update every frame, instead do it every 0.15/0.25 seconds instead, that should already help quite a lot.
To be clear, this means that humanoids are only computing the floor position, slope and material every step for the network owner of their associated assembly. Non-network owned humanoids will only compute this when .FloorMaterial is accessed?
My best guess is because a non-network owned humanoid may not actually be “fully simulated” outside certain situations, so it the FloorMaterial property is not updated. In order to keep the value accurate, we use replication.
There are other situations when a non-network owned humanoid may still compute these properties or a network owned humanoid may not compute these properties, but in general clients will compute these properties every step for the local player humanoid, and now with this change, whenever the FloorMaterial property is read.
Hi, to clarify, we are not removing the property, only changing its replication. The value of Humanoid.FloorMaterial should be accurate whenever you read it.
Unless, is there another concern in your workflow we should be aware of?
Due to this removal and the topic of it causing performance issues, is there any replacement?
I use it to determine if people are fly hacking/holding the minimize key to freeze their humanoid in the air allowing them to dodge certain things (lava rising, the floor being removed below them, etc).