How to detect if a player is not in the air?

Before you say anything, I have looked at other posts and tried to use them. But It doesnt work exactly how I would like it. Im using the humanoid state method and it works sometimes but doesnt always detect it exactly. Is there any other way I could do this? Here is my script if you wanted to see that. I’m making a pogo stick.

local Tool = script.Parent
local Power = 20
local Default = 8.5
local userinputservice = game:GetService(“UserInputService”)

Tool.Equipped:Connect(function()
local Character = Tool.Parent
local humanoid = Character.Humanoid
Character.Humanoid.JumpHeight = Power
userinputservice.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Space then
if humanoid:GetState() == Enum.HumanoidStateType.Freefall then
else

  		local particle = Tool.Handle.ParticleAttachment.ParticleEmitter
  		particle:Emit()
  		end
  	end
  end)

end)

Tool.Unequipped:Connect(function()
local Character = Tool.Parent.Parent.Character
Character.Humanoid.JumpHeight = Default
end)

I just figured it out, as soon as I posted this.

local Tool = script.Parent
local Power = 20
local Default = 8.5
local userinputservice = game:GetService(“UserInputService”)

Tool.Equipped:Connect(function()
local Character = Tool.Parent
local humanoid = Character.Humanoid
Character.Humanoid.JumpHeight = Power
userinputservice.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Space then
if humanoid.FloorMaterial == Enum.Material.Air then
else
local particle = Tool.Handle.ParticleAttachment.ParticleEmitter
particle:Emit()
end
end
end)
end)

Tool.Unequipped:Connect(function()
local Character = Tool.Parent.Parent.Character
Character.Humanoid.JumpHeight = Default
end)

sorry.

2 Likes

I used

if humanoid.FloorMaterial == Enum.Material.Air then
else
local particle = Tool.Handle.ParticleAttachment.ParticleEmitter
particle:Emit()
end

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.