How to tell what player is standing on

So i have a script that tell what player is standing on but i dont think it is the best way possible and maybe it will cuz lag anyway so what i do is
get the character of the player than i connect every part - meshpart to touch event after that i fire event to the server i can change the fire part but the isuss here is how to tell what player is standing on

-- local script in startcharacter scripts
local Character = script.Parent
local PartMaterial = nil
local replicatedStorge = game:GetService("ReplicatedStorage")
local event = replicatedStorge:WaitForChild("PressedQ")
for _,item in Character:GetChildren() do
	if item:IsA("MeshPart") or item:IsA("Part") then
		item.Touched:Connect(function(Part)
			if Part.Material ~= PartMaterial then
				event:FireServer(Part.Material)
				PartMaterial = Part.Material

				print(PartMaterial)

			end
		end)
	end
end

So is there a better way than connecting every part in the character with touch event

1 Like

As @Niveum said, FloorMaterial will get what your player is standing on.
If you want to know what is under a player while they are jumping or falling you may want to raycast straight down from the HumanoidRootPart, which can return the Material hit.

2 Likes

well ty but that was a part from the problem how could i tell what part they standing on in other way

You can shoot a raycast at the ground and get the material or part through the ray.

1 Like

Racyast,

local RaycastParam = RaycastParams.new()
RaycastParam.RespectCanCollide = true
RaycastParam.FilterType = Enum.RaycastFilterType.Exclude
RaycastParam.IgnoreWater = false

workspace:Raycast(HumanoidRootPart.Position, Vector3.yAxis*2.5, RaycastParam)
1 Like