workspace:Raycast returns nil on Terrain

When trying to use WorldRoot:Raycast() on Terrain, it returns nil. It works fine on a regular BasePart, the issue is only isolated to Terrain. I only discovered this issue today, and can’t say how long this has existed.

Code I used for testing (run in command bar):

local params = RaycastParams.new()
local Character = game.Players.LocalPlayer.Character
params.FilterDescendantsInstances={workspace.DevBuckette, workspace.CurrentCamera}
params.FilterType = Enum.RaycastFilterType.Blacklist

local Origin = Character.HumanoidRootPart.Position
local Direction = Origin - Vector3.new(0,30,0)

local result = workspace:Raycast(Origin, Direction, params)
print(result)

Simply walk onto a patch of terrain while in Test mode, and run the code.

Output when the code is run while standing on Terrain:
image

image

Output when the code is run while standing on a BasePart
image

image

I used Direction as a TargetPosition rather than an offset. Changing Direction to
Vector3.new(0,-10,0) fixed it. Post can be locked.

This looks more like a problem related to your RaycastParams or your code, I tried to cast some rays on terrain and It worked.

huh

image

Yeah, it was an issue with the Raycast’s Direction. brinkokevin kindly helped me out on Discord.