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!

2 comments
what is the nearesthumanoid supposed to do? On line 02.
If it's a function that returns you the humanoid. You forgot the (). And humanoid doesn't have a position, instead, get the humanoid root part from the humanoid parent.