Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Using Raycasting for NPC?

Asked by 9 years ago

I can easily go on the wiki to find raycasting laser guns for players but I wanted to create a ray from an npc to its target. Roblox wiki is not answering any of my questions.

while true do wait(.1)

local target = findNearestTorso(script.Parent.Torso.Position)
if target ~= nil then
    script.Parent.Torso.CFrame = (CFrame.new(script.Parent.Torso.Position,
    Vector3.new(target.Position.X, script.Parent.Torso.Position.Y, target.Position.Z)))
    -- make the ray here so every .1 seconds it shoots a ray at its target.
end

I really need help. Please take the time and help me !

Answer this question