Changes to FloorMaterial Replication

Hi developers,

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.

134 Likes

This topic was automatically opened after 10 minutes.

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

9 Likes

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!

5 Likes

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.

14 Likes

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.

7 Likes

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?

3 Likes

Is this change live now, and if not, is there a rough ETA? I’d want to set a reminder to remove my listeners.

3 Likes

i have the update :slight_smile: and nothing changes

1 Like

Sounds Cool! Is it live? I am so confused with roblox studio updates to-

2 Likes

Out of curiosity, why was this previously replicated? Regardless though, this is a nice change. Previously, clients could spoof the floor.

2 Likes

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.

1 Like

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?

2 Likes

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.

3 Likes

oof… This was really useful before, do not approve of this one…

2 Likes

Well crap. There goes my game that relied on that.

Joking, of course, it really isn’t much of a bother to just… do literally anything else to detect the floor.

Actually this is interesting, since you’re not removing the functionality, just making it not constantly replicate. Cool.

1 Like

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.

2 Likes

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?

3 Likes

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).

1 Like

its not being removed. If anything, it’ll help your anti exploit due to the property being locally calculated

2 Likes