So what I was trying to do here was make the enemy follow the player and the error, " Workspace.Enemy.Humanoid.Walk:6: attempt to index nil with 'Position'" popped up, anyone have answers?
local enmhum = script.Parent.Parent.Humanoid local nearestHumanoid = findNearestHumanoid local map if nearestHumanoid then map = nearestHumanoid.Position end while wait() do for i,v in pairs(game.Players:GetChildren())do local character = game.Workspace:WaitForChild(v.Name) enmhum:MoveTo(character.PrimaryPart.Position) script.Parent.Touched:Connect(function(hit) if hit.Parent.Name == character.Name then character.Humanoid.Health = character.Humanoid.Health == 50 if hit.Parent.Name == character.Name then character.Humanoid.Health = character.Humanoid.Health == 1 end end end) end end
Thank you!