Solved By This Person.

local UpdatePosition = 0.2 --How long it takes target the next humanoid
local DamageTime = 3 --How long it takes for the enemy to attack again
local Damage = 30 --How much damage the enemy does
--Advanced Config
local AgroDist = 100 --The amount of studs that the enemy can find you at
local HitBox = script.Parent.HitBox --Change to the part that it has to touch to deal damage (example: script.Parent.Head, script.Parent.LeftArm. Make sure it's not the rootpart though)
-- Do not edit the below unless you know what you are doing
local Player = game.Players.LocalPlayer
local enhum = script.Parent.Enemy
local ddb = false
local character
-- This is the real script. Only edit if you know what you are doing
while wait() do
	local player = game.Players.LocalPlayer
	for i, v in pairs(game.Players:GetChildren()) do
	 character = game.Workspace:WaitForChild(v.name)
		if (character.Humanoid.RootPart.Position - enhum.RootPart.Position).Magnitude <= AgroDist then
			enhum:MoveTo(character.PrimaryPart.Position)
			enhum.MoveToFinished:Wait(UpdatePosition)
		end
		end

Very confused still though!

2 comments

0

not sure if it was intended but you are missing an end in the code you posted, the while wait() do loop is still open

0

Not intended! But it was lower down for some reason. But thanks for helping me figure it out a bit, had no idea it was with the ends!