Underwater detection for players by reading voxels to a Region3 follow the head position

Hello, I was working on my game where the game detects whenever your head is underwater or not. At first I came with a while loop reading voxels approach in a script and I quickly realized that it would add too much overhead on the server, especially with a large amount of players, so I decided to offload the responsibility to the client while still having a server-side check whenever the client claimed the player got out of the water. Only problem here is the client could just never tell the server that it got underwater, so the server would still need to check once in a while for every player if they are currently underwater or not, which isn’t really a problem but I started looking at the Hearbeat event from RunService on the server side and was wondering if maybe I should keep the server checking the underwater state for each player through that event for more simplicity and reliability with less overhead than a while loop.

Are players able to swim in the Game? If so you can just use:

You can use the humanoid to detect when you start swimming, like this:

humanoid.Swimming:Connect(function()
   --your logic goes here
end)
1 Like