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

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
