How do I detect what material a player is walking on?

How do I detect what material (wood, plastic etc.) a player is walking on or what terrain type they are walking on?

1 Like


1 Like

Humanoid.FloorMaterial returns the material

Alternatively you could use ray casting. ray casting is more reliable and you can also check what material is under the player even if they’re still in the air. (You can also check in all directions too)

A quick example would be

local Player = game.players.LocalPlayer
local Character = Player.Character or Character.Added:Wait()
local HRP = Character:FindFirstChild(“HumanoidRootPart”)

while true do

Local RayParam =
RayParam.FilterDescendantsInstance = {Character}

local ray = workspace:Raycast(HRP.Position,HRP.CFrame.UpVector * -10,RayParam)

if ray then — if the ray hit a object 
local Material = ray.Instance.Material

if Material == Enum.Material.Grass then
print(“Player is on grass!”)


I have not tried this out so there may be a typo

1 Like