Hey. I want to make a script that runs an animation and plays a sound only when the player is in Air. How can I do it? This is what I have so far:
player = game.Players.LocalPlayer
mouse = player:GetMouse()
local character = game.Players.LocalPlayer.Character
Humanoid = character.Humanoid
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=2161945388"
local animTrack = Humanoid:LoadAnimation(animation)
local GlideSound = Instance.new("Sound", workspace)
GlideSound.SoundId = "http://www.roblox.com/Asset?ID=1000941579"
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.R then
print("R was pressed")
animTrack:Play()
GlideSound:Play()
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

2 comments
https://wiki.roblox.com/index.php?title=API:Enum/HumanoidStateType Use this to check if the player is in the Jumping or Freefall State, or just Freefall if you want it to be when they are falling
Can someone check the HealthBar question?