Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How do I get a conditional statement with FloorMaterial being Air?

Asked by
Launderer 343 Moderation Voter
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.

1if Character.Humanoid.FloorMaterial == Enum.FloorMaterial.Air then
2local Gravity = Instance.new("BodyVelocity", Character.HumanoidRootPart)
3Gravity.Name = "Gravity"
4Gravity.Velocity = Vector3.new(0, -2, 0)
5Gravity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
6end

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.

1Character.Humanoid.FreeFalling:connect(function()
2local Gravity = Instance.new("BodyVelocity", Character.HumanoidRootPart)
3Gravity.Name = "Gravity"
4Gravity.Velocity = Vector3.new(0, -2, 0)
5Gravity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
6end)
0
With what you need help? `If FloorMaterial = Enum.Material.Air then` do the code that's all. superalp1111 662 — 6y
0
That's the same as first Script, just identify the Materials of your ground, change 'Air' into Type of Material of your ground User#17685 0 — 6y
0
To have it stop you would do Character.HumanoidRootPart.BodyVelocity:Destroy() or :Remove() TiredMelon 405 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
1Character.Humanoid.FreeFalling:connect(function()
2    local Gravity = Instance.new("BodyVelocity", Character.HumanoidRootPart)
3    Gravity.Name = "Gravity"
4    Gravity.Velocity = Vector3.new(0, -1, 0)
5    Gravity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
6    repeat wait() until Character.Humanoid.FloorMaterial ~= Enum.Material.Air
7    Gravity:Destroy()
8end)
Ad

Answer this question