I have this script, but it’s not accurate, even if the player is on the ground, the ground is detected like 3-4 studs above.
local function findGround()
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Include
raycastParams.FilterDescendantsInstances = {workspace.InvisibleMapBarriers}
local rootPart_p: Vector3 = plr.Character.HumanoidRootPart.Position
local raycast = workspace:Raycast(rootPart_p, Vector3.new(rootPart_p.X, rootPart_p.Y - 1000000, rootPart_p.Z), raycastParams)
local raycast_p = raycast.Position
return raycast_p.Y
end
Why are you using Enum.RaycastFilterType.Include instead of Enum.RaycastFilterType.Exclude? Also, like mentioned above, add the player’s character to the table.