Problem with landing detection (Raycasting)

Hello, I am making a combat system for a game. I am currently trying to make the downslam attack as a combo ender. Everything is fine with the downslam besides the ground detection. I am trying to make it detect the ground so I could make a rock circle effect. Theres a problem though. The ground detection is SUPER innacurate and sometimes it doesnt even work. Any ideas how to fix this?


local rootPart = v.Parent.HumanoidRootPart -- v.Parent is the enemy's char.
							local rootPartHeight = v.Parent.Humanoid.HipHeight + rootPart.Size.Y / 2; -- calculate height of the root part from the bottom of the character

							local rayParams =
							rayParams.FilterDescendantsInstances = {v.Parent,player.Character}
							rayParams.FilterType = Enum.RaycastFilterType.Blacklist

								local raycast = workspace:Raycast(rootPart.Position,, -9000, 0), rayParams)
								local distance;

								if raycast then
									distance = (rootPart.Position - raycast.Position).Magnitude

							until distance and distance <= rootPartHeight

Example video: problem with landing detection

thanks in advance!

Maybe listen for Humanoid.StateChanged instead of using Raycasting?

Humanoid.StateChanged:Connect(function(_, NewState : Enum.HumanoidStateType)
	if NewState ~= Enum.HumanoidStateType.Landed then return end

I tried using that but its innacurate sometimes. I dont know why