function Enemy.new(G,w,E,a)assert(enemies[G],"\073\110\118\097\108\105\100 \101\110\101\109\121 \116\121\112\101")local A=setmetatable({},Enemy)A._model=enemies[G]:Clone()A._model.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping,false)A._model.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Climbing,false)A._model.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Swimming,false)A._model.Humanoid.MaxHealth=GameSettings.EnemyHealthDifficulty[a]A._model.Humanoid.Health=GameSettings.EnemyHealthDifficulty[a]CollectionService:AddTag(A._model,"\069\110\101\109\121")A._model.Humanoid.Died:Connect(function()A:_destroy()end)A._model.HumanoidRootPart.Touched:Connect(function(G)A:_onTouch(G)end)A._target=E A._active=false A._model:SetPrimaryPartCFrame(w)A._model.Parent=game.Workspace.Targets return A end function Enemy._update(G)if G._model and G._model:FindFirstChild("\072\117\109\097\110\111\105\100")then local w=G._target.PrimaryPart.Position local E=G._target.PrimaryPart.AssemblyLinearVelocity local a=w+E*4 G._model.Humanoid:MoveTo(w)end end
-- Enemy constructor
function Enemy.new(enemyType, location, target, difficulty)
	assert(enemies[enemyType], "Invalid enemy type")

	local self = setmetatable({}, Enemy)

	self._model = enemies[enemyType]:Clone()

	-- Disable unnecessary behaviors of humanoid to make game more efficient
	self._model.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
	self._model.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Climbing, false)
	self._model.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Swimming, false)

	-- Set enemy health based on difficulty
	self._model.Humanoid.MaxHealth = GameSettings.EnemyHealthDifficulty[difficulty]
	self._model.Humanoid.Health = GameSettings.EnemyHealthDifficulty[difficulty]

	-- Tag the enemy's model
	CollectionService:AddTag(self._model, "Enemy")

	self._model.Humanoid.Died:Connect(function()
		self:_destroy()
	end)

	self._model.HumanoidRootPart.Touched:Connect(function(otherPart)
		self:_onTouch(otherPart)
	end)

	self._target = target
	self._active = false

	self._model:SetPrimaryPartCFrame(location)
	self._model.Parent = game.Workspace.Targets

	return self
end

function Enemy:_update()
	if self._model and self._model:FindFirstChild("Humanoid") then
		local targetPosition = self._target.PrimaryPart.Position
		local targetVelocity = self._target.PrimaryPart.AssemblyLinearVelocity
		local predictedPosition = targetPosition + targetVelocity * 4
		self._model.Humanoid:MoveTo(targetPosition)
	end
end
