Since nobody answered on Port zombie that made out of parts into proper r6 zombie character , I started making my own zombie ai, which will work close to https://create.roblox.com/marketplace/asset/201169102/Realistic-Zombie-AI but with proper limbs.
And so i ran into a problem that i dont know how to cast ray from single zombie to all players to later check closest player that is being seen by zombie.
loop through all players and make the following ray
local ray = Ray.new(zombieroot.Position,
(playerroot.Position-zombieroot.Position).Unit*1000)
the problem is i have no idea how to loop raycast to each player, and not skipping anybody, read carefully before actually answering please
try this, might not work cause i wrote it on mobile :0
-- services
local players = game:GetService("Players")
-- variables
local zombie = script.Parent --????
local zroot = zombie:WaitForChild("HumanoidRootPart")
-- raycasting to all players
while task.wait() do
for _, player in pairs(players:GetPlayers()) do
local character = player.Character
local root = character:FindFirstChild("HumanoidRootPart")
if character and root then
local ray = Ray.new(
zroot.Position,
(root.Position-zroot.Position)
)
local ignore = {zombie}
local hit = workspace:FindPartOnRayWithIgnoreList(ray,ignore,false,true)
end
end
end