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 =
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 -,30,0)

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

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:


Output when the code is run while standing on a BasePart


I used Direction as a TargetPosition rather than an offset. Changing Direction to,-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.



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