How to get part color from Raycast

How can I get color from Raycast. I was gonna use FindPartOnRay but apparently that was deprecated (no clue when)

local SetRaycastParams = RaycastParams.new()
SetRaycastParams.FilterType = Enum.RaycastFilterType.Blacklist
SetRaycastParams.FilterDescendantsInstances = {Character}
			
local NewRay = workspace:Raycast(Character.HumanoidRootPart.Position, Vector3.new(0, -10, 0), SetRaycastParams)
print(NewRay)
print(NewRay.Color)

RaycastResult{Grass @ -4.98748779, 9.5, -13.1847439; normal = 0, 1, 0; material = SmoothPlastic}

1 Like

Try this

local SetRaycastParams = RaycastParams.new()
SetRaycastParams.FilterType = Enum.RaycastFilterType.Blacklist
SetRaycastParams.FilterDescendantsInstances = {Character}
			
local NewRay = workspace:Raycast(Character.HumanoidRootPart.Position, Vector3.new(0, -10, 0), SetRaycastParams)
print(NewRay)
print(NewRay.Instance.BrickColor)
1 Like

workspace:Raycast returns a RaycastResult

local raycastResult = workspace:Raycast(Character.HumanoidRootPart.Position, Vector3.new(0, -10, 0), SetRaycastParams)

You can get the BasePart or Terrain by doing this

local hitPart = raycastResult.Instance

and the color with this

hitPart.Color

here the tutorial

8 Likes