I'm trying to make it so the Zombie can detect a player coming from using ray casting but it isn't working! Here is my code.
local ray = Ray.new(script.Parent.Head.Position,(script.Parent.Torso.Position + Vector3.new(50,10,50) - script.Parent.Torso.Position).Unit * 300)
local hit, position = workspace:FindPartOnRay(ray,nil,false,false)
if hit then
if hit.Parent:FindFirstChild('Humanoid') and hit.Parent:FindFirstChild('Torso') then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
script.Parent.Humanoid:MoveTo(hit.Parent.Torso.Position)
end
end
end

1 comment
Thanks! I totally forgot about the path finding service!