-- Zombie Controller
-- by alphagamer150
-- Get services
local PathfindingService = game:GetService("PathfindingService")
local Players = game:GetService("Players")
-- Create varibles
local Zombie = script.Parent
-- Main Loop
-- while not Python:
while wait() do
local PlayerList = Players:GetPlayers()
local LowestDistance = 0
local ClosestPlayer
for i = 1, #PlayerList do
local PlayerPos = game.Workspace:FindFirstChild(PlayerList[i].Name).HumanoidRootPart.Position
local ZombiePos = Zombie.HumanoidRootPart.Position
print(PlayerPos)
if (PlayerPos - ZombiePos).magnitude < LowestDistance then
print("Test")
end
end
end
Script above keeps giving me 19:36:12.091 - Workspace.Zombie.Script:18: attempt to index a nil value

3 comments
we can't help you if you don't show line 18
Fixed
try local PlayerPos = game.Workspace:WaitForChild(PlayerList[i].Name).HumanoidRootPart.Position