-- Create the enemy death event handler

game.Workspace.OnCharacterAdded:Connect(function(character)
	-- Check if the character is an enemy
	if character:FindFirstChild("Humanoid") and character:FindFirstChild("Enemy") then
		-- Remove the enemy from the game state
		for i, enemy in pairs(gameState.enemies) do
			if enemy == character then
				table.remove(gameState.enemies, i)
				break
			end
		end

		-- Check if the level is complete
		if #gameState.enemies == 0 then
			-- Load the next level
			loadLevel(gameState.level + 1)
		end
	end
end)
