How do I make a raycast and fire it?

I’m trying to detect if my player touched the ground or not, so I’m going to fire a raycast to check.

I’m not sure how to do this though…

1 Like

It is kind of unclear what you exactly want, but assuming you have knowledge of raycasts.
Cast a raycast from the root part of the player, and check if there is a result. (Add params to prevent hitting yourself)

local RaycastResult = Workplace:Raycast(HumanoidRootPart.Position, HumanoidRootPart.Position - Vector3.new(0,-3,0)) --Made this on a whim, you may need to change the Y value there.

(Alot easier way of doing this is humanoid.floormaterial, if there isn’t a floor material then they are in air)

If your game is R15 then you could ray cast from the character’s feet to see how close they are to the ground

There are plenty of posts about this topic, as well as the Roblox documentation:
<Raycasting | Roblox Creator Documentation
<Intro to Raycasting