How to make a raycasting gun

Construct a raycastparams, then set its FilterType to Enum.RaycastFilterType.Blacklist and add the character to the FilterDescendantsInstances.

local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
params.FilterDescendantsInstances = { player.Character }

...
local result = Workspace:Raycast(origin, direction, params)
9 Likes