How Do i Detect If the Player's Feet Are Touching Something (Without Raycasting)

Hello. This might be a weird topic But i wanted to know how Do i detect if the Player’s Feet is touching a Specific Part like the Baseplate?. Without Raycasting?

1 Like

Why don’t you want to raycast?
I would say the best approach to this would be to do a blockcast below the player whenever they touch the baseplate.

Something like this:

local Players = game:GetService("Players")
local Trigger = workspace.Baseplate -- Your part

Trigger.Touched:Connect(function(Part: BasePart)
    local Player = Players:GetPlayerFromCharacter(Part.Parent)
    if not Player then return end -- Check if it is a player that touched it

    local Params = RaycastParams.new()
    Params.FilterDescendantsInstances = {Trigger}
    Params.FilterType = Enum.RaycastFilterType.Include

    local RootPart = Part.Parent:FindFirstChildOfClass("Humanoid").RootPart
    local Origin = RootPart.CFrame * CFrame.new(0, -2.5, 0)

    local Result = workspace:Blockcast(Origin, Vector3.new(1.9, 0.5, 0.9), -Vector3.yAxis, Params)

    if Result and Result.Instance then
        -- The player is standing on the baseplate
    end
end)

You could use GetPartBoundsInBox

But I’d say that raycasting is probably the better option (especially when you’re doing it alot)

Using a Custom Floor Check with Region3, GetTouchingParts(), or Touched event

check if the humanoid’s floortype value is air

1 Like

Region3-based spatial querying has been deprecated for over 3 years now

You could add a ControllerPartSensor to the player’s Character. This instance is based on the same logic for movement as Humanoid, but it also comes with a SensedPart property, which you could listen for a change to and then check if it’s the specific part you’re after.

1 Like

My script is Already 60 Lines Long. i Didn’t want to extend it Further. And yes i know how raycasting works and will probbably do it. But thanks.

It’s a good idea to be mindful of script size, as the larger the script, the messier it tends to get. However it should not be a limiting factor in your design decisions. If you struggle to keep the size of scripts down, consider using module scripts, and splitting off generic functions into those.

Do you want to detect if it is touching a part in general or a specific part? If in general, you can just do what @Cookie941_9 said and

check if the humanoid’s floortype value is air

It can be done like so:

if humanoid.FloorMaterial ~= Enum.Material.Air then
1 Like