luaairtouchroblox

How to know how much time the player is in air (Roblox)?


I just created a Roblox game of shooting. The main target of the game is to stay alive as long as possible. But I recently noticed while playing other games that people use mods for flying in air. (In simple words 'hacking').

If the people use that in my game also they might be the one and only winner always.

So I decided to check when a player is not touching any object (In air) for more than 5 seconds the the player should die.

But then I searched In Google if there are any ways that I can do that. But found none. If anyone know how to achieve that can please help me...

Thanks in advance


Solution

  • This is the result of my 1 minute google search, no idea what you searched for...

    From: https://developer.roblox.com/en-us/api-reference/property/Humanoid/FloorMaterial

    When the Humanoid is not standing on a floor, the value of this property will be set to Air.

    The code sample below demonstrates how to listen to when this property changes using Instance:GetPropertyChangedSignal

    So if the material changed to Air you start a 5 second timer. If the player lands stop the timer. When the timer finishes, kill the player.

    There are some comments that FloorMaterial might be problematic if the player is swimming. So probably use https://developer.roblox.com/en-us/api-reference/event/Humanoid/StateChanged to start and stop the timer.

    That should give you plenty of starting points. I won't give you any code. Make yourself familiar with the examples and you'll come up with a solution quickly.