Hello.
Alright, so I have a problem with a raycast that I am trying to make. What I am trying to do is make a raycast shoot out of an npc, and I want the raycast to detect the rootpart of the player when its hit.
Here is what I have so far.;
while task.wait() do
if point == nil then
break
end
local raycast_params = RaycastParams.new()
raycast_params.FilterType = Enum.RaycastFilterType.Include
raycast_params.FilterDescendantsInstances = {enemy_npc}
local right_raycast = workspace:Raycast(enemy_npc_hrp.Position, enemy_npc_hrp.CFrame.LookVector * 20, raycast_params)
if right_raycast and right_raycast.Instance then
if (right_raycast.Instance == hrp) then
print("success")
else
print("fail")
end
end
end
All this code does is just always return the “fail” statement, and it never succeeds to detecting the player’s rootpart. Am I doing something wrong? Please let me know.
Thank you.