So I made this script to detect for how much time the player has been in the free-falling state so if they jump off of something it would play a wind sound. but the only problem is if the character is falling forward so a dash forward their state would be free fall so it would trigger the sound. Is there any other way to make the sound play only if the player’s Y velocity is higher than a specific number? This is my script that uses free falling:
local SoundService = game:GetService("SoundService")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local Humanoid = char:WaitForChild("Humanoid")
local sound = SoundService.Wind
local Volume = 3
local StartTime
Humanoid.StateChanged:Connect(function(OldState,NewState)
if NewState == Enum.HumanoidStateType.Freefall then
StartTime = tick()
delay(.5, function()
if tick() - StartTime >= .5 and Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
sound.Volume = 0
sound:Play()
for count = 1,15 do
local Incr = Volume/15
sound.Volume = sound.Volume + Incr
wait(0.1)
end
end
end)
elseif Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
sound:Stop()
end
end)
Example of my game: