I’m trying to check if the player has landed (touched the ground, no longer in the air)
I have tried using Humanoid.StateChanged and Humanoid.FloorMaterial to check if player has landed on the ground. When I used StateChanged, it doesn’t detect the player landing half of the time. When I used FloorMaterial, it works normally but sometimes when you get near certain parts or even not near parts it thinks your floormaterial is plastic when you’re actually in the air.
I would really appreciate other ideas to check if the player has landed.
note: this is for double jumping
local UIP = game:GetService("UserInputService")
local humanoid = script.Parent:WaitForChild("Humanoid")
local debounce = false
UIP.InputBegan:Connect(function(Key, IsTyping)
if IsTyping then return end
if not debounce and humanoid:GetState() == Enum.HumanoidStateType.Freefall and Key.keyCode == Enum.KeyCode.Space then
debounce = true
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
end)
humanoid.StateChanged:Connect(function(state)
if debounce and state == Enum.HumanoidStateType.Landed then
debounce = false
elseif debounce and state == Enum.HumanoidStateType.Climbing then
debounce = false
end
end)
thats a local script on starter character scripts.
if your using server script on the landed maybe it has bit of delay
local Hum = game.Players.LocalPlayer.Character.Humanoid
Hum.StateChanged:Connect(function(newState)
if newState == Enum.HumanoidStateType.Landed then
--Something
end
end)
Like I said, I’ve tried using Landed it doesn’t execute the code inside the if statement appropriately half of the time. I am using it on the client so it shouldn’t be delayed at all. I also use JumpRequest instead of UIS.InputBegan.
hum.StateChanged:Connect(function(oldState,newState)
if newState == Enum.HumanoidStateType.Freefall then
hum.WalkSpeed += 30
wait(0.2)
debounce1 = true
elseif newState == Enum.HumanoidStateType.Landed then
if Character["LeftHand"]:FindFirstChild("Trail") then
Character.LeftHand.Trail:Destroy()
end
if Character["RightHand"]:FindFirstChild("Trail") then
Character.RightHand.Trail:Destroy()
end
debounce1 = false
end
end)
Now I’ve identified a different issue, apparently landed works fine however if I continue to move around when I land instead of stopping as soon as I land, it will not destroy the trail, anyone know why? It finds the trail correctly and it says it should’ve destroyed.