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.
if Character.Humanoid.FloorMaterial == Enum.FloorMaterial.Air then local Gravity = Instance.new("BodyVelocity", Character.HumanoidRootPart) Gravity.Name = "Gravity" Gravity.Velocity = Vector3.new(0, -2, 0) Gravity.MaxForce = Vector3.new(math.huge, math.huge, math.huge) end
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.
Character.Humanoid.FreeFalling:connect(function() local Gravity = Instance.new("BodyVelocity", Character.HumanoidRootPart) Gravity.Name = "Gravity" Gravity.Velocity = Vector3.new(0, -2, 0) Gravity.MaxForce = Vector3.new(math.huge, math.huge, math.huge) end)
Character.Humanoid.FreeFalling:connect(function() local Gravity = Instance.new("BodyVelocity", Character.HumanoidRootPart) Gravity.Name = "Gravity" Gravity.Velocity = Vector3.new(0, -1, 0) Gravity.MaxForce = Vector3.new(math.huge, math.huge, math.huge) repeat wait() until Character.Humanoid.FloorMaterial ~= Enum.Material.Air Gravity:Destroy() end)