Details I want to know how to use Ray cast and implement that to detect if the npc is infront of the Player. I do not want it to detect players through walls , only in the range of the NPC.
COMMUNITY QUESTION
How do I create Raycast and use it to detect a player near by?
1 answer
this is very simple use find part on ray
in script
local npc = script.Parent
while wait(1) do
local ray= Ray.new(npc.HumanoidRootPart.Position, npc.HumanoidRootPart.CFrame.lookVector)
if FindPartOnRay(ray).Parent.Humanoid then
-- ur code
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
