I want to make a system that finds if the player is standing in a “Grass” part. However, when I try to downcast (raycast downwards), the part being returned is not the part that is beneath the player. It is usually a part that is to the side of the player
This is my current code:
local function getGround()
local char = player.Character or player.CharacterAdded:Wait()
local hrp = char:WaitForChild('HumanoidRootPart')
local rp = RaycastParams.new()
rp.FilterDescendantsInstances = {char}
rp.FilterType = Enum.RaycastFilterType.Blacklist
rp.IgnoreWater = true
local rr = workspace:Raycast(hrp.Position, hrp.Position-Vector3.new(0, 10, 0), rp)
if not rr then return false end
if rr.Instance then
print(rr.Instance:GetFullName())
if rr.Instance.Parent.Name == 'Grass' and rr.Instance.Name == 'Grass' then
return true
end
end
return false
end
I tried setting the Y value of the Vector3 to a higher value but that resolved nothing. Thanks in advance!