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

How do i detect player being in air to make them get a speed boost? and a sound?(Answered)

Asked by 4 years ago
Edited 4 years ago
01local bullet= game.ServerStorage.FallingSFX
02local bulletClone= bullet:Clone()
03bulletClone.Parent= script.Parent.Torso
04while true do wait()
05if script.Parent.Humanoid.FreeFalling==true  then
06script.Torso.FallingSFX.Playing=true
07script.Parent.Humanoid.WalkSpeed=script.Parent.Humanoid.WalkSpeed+10
08wait(0.25)
09script.Parent.Humanoid.WalkSpeed=script.Parent.Humanoid.WalkSpeed-10
10print("Print")
11end
12end
13while true do wait()
14if script.Parent.Humanoid.FreeFalling==false then
15script.Torso.FallingSFX.TimePosition=0
16script.Torso.FallingSFX.Playing=false
17print("Print2")
18end
19end

Correct code:

1while true do
2    wait()
3    if (script.Parent.Humanoid.FloorMaterial == Enum.Material.Air) then
4        print("They're in the air")
5    else
6        print("They're on the ground")
7    end
8end

1 answer

Log in to vote
1
Answered by
Rinpix 639 Moderation Voter
4 years ago

You can use the FloorMaterial property of Humanoid:

01local plr = game.Players.PlayerName
02 
03while true do
04    wait(1)
05    if (plr.Character.Humanoid.FloorMaterial == Enum.Material.Air) then
06        print("They're in the air")
07    else
08        print("They're on the ground")
09    end
10end
0
some changing was needed MadnessMyth 10 — 4y
Ad

Answer this question