I have a raycast function (from complexo, turned into workspace:Raycast() by me) but it returns nil when a part is literally in front of it
Range is 384
Raycast Function:
local function Raycast(origin, target, range, ignore)
range = range or (target - origin).Magnitude
local ray = Ray.new(origin, (target - origin).Unit * range)
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
raycastParams.FilterDescendantsInstances = {ignore}
raycastParams.IgnoreWater = true
local raycastResult = workspace:Raycast(ray.Origin, ray.Direction, raycastParams)
print(raycastResult)
if raycastResult then
return raycastResult
end
return nil
end
A chunk of code that uses raycast:
local ignoreList = {}
for _, v in pairs(Character:GetChildren()) do
if v:IsA('BasePart') then
table.insert(ignoreList, v)
end
end
local raycastPart = Raycast(Character.PrimaryPart.Position, targetplr.PrimaryPart.Position, RangedAttackRange, ignoreList)
this raycast ignores parts that is a part of the character (the one npc that goes to the nearest player and destroys them)
Issue count with my NPC: 2 (Making NPC go back when it is near a player and Raycast Issue)