How do I get a conditional statement with FloorMaterial being Air?
Asked by
6 years ago Edited 6 years ago
Okay I need some help here. Basically I need it so if the player is in the air it creates a bodyvelocity to push them to the ground. I felt that FloorMaterial would be the correct way to do this however I'm not seeing a lot of information about it on the wikis and what not. I found out that if you arn't standing on anything the FloorMaterial is Air. So if someone can help me with this it'd be much appreciated.
1 | if Character.Humanoid.FloorMaterial = = Enum.FloorMaterial.Air then |
2 | local Gravity = Instance.new( "BodyVelocity" , Character.HumanoidRootPart) |
3 | Gravity.Name = "Gravity" |
4 | Gravity.Velocity = Vector 3. new( 0 , - 2 , 0 ) |
5 | Gravity.MaxForce = Vector 3. new( math.huge , math.huge , math.huge ) |
edit:
Okay so I just discovered the FreeFalling event, https://wiki.roblox.com/index.php?title=API:Class/Humanoid/FreeFalling It work's and all however I don't know how to stop it when they hit the ground so if someone could now advise me on that I'd be all set.
1 | Character.Humanoid.FreeFalling:connect( function () |
2 | local Gravity = Instance.new( "BodyVelocity" , Character.HumanoidRootPart) |
3 | Gravity.Name = "Gravity" |
4 | Gravity.Velocity = Vector 3. new( 0 , - 2 , 0 ) |
5 | Gravity.MaxForce = Vector 3. new( math.huge , math.huge , math.huge ) |